Skip to main content

Dynamic Subcategories

The Dynamic Subcategories app automatically displays subcategories on collection pages in your Shopify store. Depending on the selected data source, subcategories are either pulled from a navigation menu's child links or from a collection metafield and rendered in the storefront. The appearance is fully controlled through the Theme Editor and can be further extended with custom CSS.

How It Works

The block is implemented as a Theme App Extension and is loaded as a section block in the Theme Editor. When a page loads, the Liquid template reads the current collection and determines its subcategories — either by traversing the navigation menu or by reading the custom.subcategories metafield. Custom CSS configured in the Admin interface is stored in a shop metafield and embedded directly into the page.

Installation

The app is installed via the Shopify App Store. After installation, the Dynamic Subcategories block automatically appears in the Theme Editor under Sections → Blocks. Add the block to your collection template and configure it directly in the editor.

Data Sources

With this source, you select a navigation menu that maps your collection hierarchy. The Liquid template searches the menu for an entry whose handle matches the current collection. The direct child links of that entry are displayed as subcategories.

Requirements:

  • A navigation menu with the current collection as a parent entry
  • The desired subcategories must be set up as direct child links of that entry

Example menu structure:

Clothing  →  /collections/clothing
├── Jackets → /collections/jackets
├── Pants → /collections/pants
└── Shirts → /collections/shirts

When visiting the Clothing collection, Jackets, Pants, and Shirts will be displayed as subcategories.

Metafield

With this source, the custom.subcategories metafield of the current collection is read. Collections stored there are displayed directly as subcategories. The metafield must be of type Collection (list).

Requirements:

  • The desired subcategories must be entered in the metafield on each respective collection

The custom.subcategories metafield definition is automatically created the first time the app is opened in the Shopify Admin.

Layouts

Grid

Displays subcategories in a multi-column grid. The number of columns is freely configurable (2–5). On smaller screens, the grid automatically reduces to 2 columns (≤ 768 px) or a single column (≤ 480 px).

Displays subcategories in a horizontally scrollable view with navigation buttons on the left and right. Buttons are automatically disabled when the beginning or end of the list is reached. The carousel dynamically calculates tile width based on the current container width and responds to window resize events.

List

Displays subcategories stacked vertically. Image (if enabled) and text are shown side by side. On small screens (≤ 480 px), the layout automatically switches to a stacked vertical arrangement.

Settings

All settings are configured directly on the block in the Shopify Theme Editor.

Data Source

SettingTypeDefaultDescription
Data sourceSelectNavigation menuChoose between Navigation menu and Metafield
MenuMenu selectNavigation menu to use (only for data source Navigation menu)

Layout

SettingTypeDefaultDescription
LayoutSelectGridGrid, Carousel, or List
ColumnsRange3Number of columns (2–5); Grid and Carousel only
GapRange16 pxSpacing between items (0–48 px, step: 4 px)

Images

SettingTypeDefaultDescription
Show imageCheckboxYesEnables display of the collection image
Image ratioSelectSquareAspect ratio: Square (1:1), Landscape (16:9), or Portrait (2:3)
Image radiusRange4 pxCorner radius of images (0–40 px, step: 2 px)

Images are delivered responsively with srcset and sizes (300 w, 600 w, 900 w) and load via lazy loading. A hover effect scales the image slightly to 105%.

Typography

SettingTypeDefaultDescription
Font sizeRange16 pxFont size for category titles (10–28 px, step: 1 px)
Show descriptionCheckboxYesDisplays the collection description below the title; HTML is stripped and text is truncated to 120 characters

These settings are only visible when the Carousel layout is selected.

SettingTypeDefaultDescription
Button sizeRange40 pxSize of navigation buttons (28–56 px, step: 4 px)
Button styleSelectFilledStyle: Filled (white background, shadow), Outlined (transparent, border), or Minimal (no background, no border)

Custom CSS

Custom CSS for the block can be added on the app settings page in the Shopify Admin. The CSS is stored in the shop metafield $app:custom_css and embedded directly into the <head> on each page load.

The admin interface validates CSS in real time using the css-tree library and shows syntax errors with line numbers before saving.

CSS Variables

The block exposes the following CSS custom properties, set via the Theme Editor settings:

VariableDescriptionDefault
--dsc-columnsNumber of columns3
--dsc-gapSpacing between items16px
--dsc-image-radiusImage corner radius4px
--dsc-font-sizeTitle font size1rem (16px)
--dsc-btn-sizeCarousel button size40px

CSS Classes

ClassElementNotes
.dsc-containerMain containerHas data-layout (grid/carousel/list) and data-carousel-btn-style attributes
.dsc-itemIndividual subcategory item (link)
.dsc-item__imageImage containerAdditional modifier classes: --square, --landscape, --portrait
.dsc-item__image imgThe actual imageHover zoom applied via .dsc-item:hover
.dsc-item__contentText container (title + description)
.dsc-item__titleSubcategory title (<h3>)
.dsc-item__descriptionDescription text
.dsc-carousel__trackScrollable carousel track
.dsc-carousel__btnBoth navigation buttonsModifiers: --prev, --next
.dsc-empty-statePlaceholder in Theme Editor modeOnly visible in Design Mode

Example

.dsc-container {
padding: 1rem 0;
}

.dsc-item__title {
color: #1a1a2e;
font-weight: 700;
}

.dsc-item__image {
border: 2px solid #e8e8e8;
}

Behavior in the Theme Editor

When the app is opened in the Shopify Theme Editor (Design Mode), the block displays contextual hints if no subcategories are found:

  • No menu selected or menu has no entries → hint to select a menu
  • Collection not linked in the menu → hint that no entry was found for the current collection
  • Metafield empty → hint to populate the custom.subcategories metafield

In the regular storefront, these hints are not shown — the block simply renders nothing if no data is available.

Responsive Behavior

BreakpointGridListCarousel
> 768 pxConfigured column countSide by side (image + text)Configured column count
≤ 768 px2 columnsSide by sideConfigured column count
≤ 480 px1 columnStacked verticallyConfigured column count

The carousel calculates its tile width dynamically based on the current container width and automatically adapts to window size changes via a ResizeObserver.