Unlock Dynamic Navigation: Custom Menus on Specific Shopify Dawn Pages Using Metafields

Hey everyone! Your friendly Shopify expert here, diving into a really cool and super practical customization that came up in the community forums recently. We all know how important navigation is for user experience, right? Sometimes, a single, one-size-fits-all menu just doesn't cut it. You might have special landing pages, commercial sections, or specific campaigns where you want a completely different menu to guide your customers.

That's exactly what one store owner, steveng9, was grappling with. They wanted to display a custom menu for a select group of pages on their Shopify Dawn 2.0 store, while keeping the default menu everywhere else. The brilliant idea? Using a page metafield as the switch. It's a common challenge, and thankfully, our community stepped up with some fantastic, actionable advice.

The Challenge: Conditional Menus with Metafields

steveng9 wanted to use a true/false page metafield (page.metafields.custom.commercial_menu) to determine which menu to show. If the metafield was 'true' for a specific page, an 'alternate menu' should appear. Otherwise, the standard 'default menu' should remain. They'd already tried assigning a new variable, new_menu, based on this logic within the header snippets, but things weren't quite clicking.

This kind of dynamic content display is a game-changer for many businesses. Imagine having a dedicated menu for your wholesale portal, or a simplified navigation for a specific product launch page that doesn't distract visitors with your main store categories. It makes your store incredibly versatile, allowing you to tailor the experience precisely.

Community Wisdom: Key Insights from Ploqo and Maximus3

The beauty of the Shopify community is how quickly experts jump in to help. Ploqo and Maximus3 both chimed in with incredibly helpful solutions that clarified a few critical points. Their combined wisdom really honed in on the best approach.

1. Boolean Metafields Need True Boolean Comparison

One of the first things both experts highlighted was a common Liquid pitfall: comparing a boolean metafield's value. steveng9 had initially used page.metafields.custom.commercial_menu.value == 'true'. However, as Maximus3 pointed out, a true/false metafield's value is a boolean (true or false), not a string ('true' or 'false'). The correct comparison is page.metafields.custom.commercial_menu.value == true (without quotes).

2. Dawn Theme's Multi-Part Menu Structure

Another crucial insight, particularly from Ploqo, was understanding how the Dawn theme handles its navigation. Unlike some simpler themes, Dawn breaks its header menu into multiple snippets to accommodate different layouts (dropdown, mega menu, mobile drawer). This means you can't just modify one file; you need to apply the logic in all relevant places:

  • snippets/header-dropdown-menu.liquid (for desktop dropdowns)
  • snippets/header-mega-menu.liquid (for desktop mega menus)
  • snippets/header-drawer.liquid (for the mobile menu, and desktop if you use the drawer layout)

This ensures your custom menu appears consistently across all devices and menu styles.

3. Scoping with template.name

Both solutions emphasized including template.name == 'page' in the conditional logic. This is a smart move because it ensures your custom menu logic only applies to regular pages. You wouldn't want your product pages, collection pages, or homepage suddenly showing an unexpected menu, right? This keeps the customization tightly scoped to where it's intended.

Step-by-Step Guide: Implementing Your Dynamic Menu

Alright, let's put this community wisdom into action! Here's how you can set up a custom menu for specific pages in your Dawn theme, based on a page metafield:

Step 1: Create Your Alternate Menu

First things first, you need the actual menu you want to display. Go to your Shopify Admin:

  1. Navigate to Online Store > Navigation.
  2. Click Add menu.
  3. Give it a descriptive title (e.g., "Commercial Pages Menu") and save it.
  4. Add the menu items you want for this special navigation.
  5. Make a note of the menu's handle. For example, if your menu title is "New Menu", its handle will likely be new-menu. You'll use this in your code.

Step 2: Create Your Page Metafield

Next, we need the switch that tells Shopify which menu to show:

  1. In your Shopify Admin, go to Settings > Custom data.
  2. Under Metafields, click on Pages.
  3. Click Add definition.
  4. Set up your metafield:

    • Name: Something clear like "Commercial Menu"
    • Namespace and key: custom.commercial_menu (this is what steveng9 used, and it's good practice)
    • Content type: Select True or false.
    • Save your definition.
  5. Now, when you edit any page (Online Store > Pages), you'll see this new metafield at the bottom. Tick the box for any page where you want the alternate menu to appear. Leave it unticked for pages that should keep the default menu.

Step 3: Edit Your Theme Code

This is where we implement the logic shared by Ploqo and Maximus3. Always remember to duplicate your theme before making any code changes!

  1. Go to Online Store > Themes.
  2. Find your Dawn theme, click Actions > Edit code.
  3. You'll need to open these three files:

    • snippets/header-dropdown-menu.liquid
    • snippets/header-mega-menu.liquid
    • snippets/header-drawer.liquid
  4. At the very top of each of these three files, paste the following Liquid code:

    {%- if template.name == 'page' and page.metafields.custom.commercial_menu.value == true -%}
      {%- assign header_menu = linklists['new-menu'].links -%}
    {%- else -%}
      {%- assign header_menu = section.settings.menu.links -%}
    {%- endif -%}
    

    Important: Replace 'new-menu' with the actual handle of the alternate menu you created in Step 1.

  5. Next, find the menu loop in each of those three files. It typically looks like this:

    {%- for link in section.settings.menu.links -%}
    
  6. Change that line to use our newly assigned header_menu variable:

    {%- for link in header_menu -%}
    

  7. Save your changes to all three files.

Step 4: Test Thoroughly!

This is crucial! Visit your store and check:

  • Pages where the metafield is ticked: Do they show the new, custom menu?
  • Pages where the metafield is NOT ticked: Do they show the default menu?
  • Product pages, collection pages, blog posts, and the homepage: Do they all show the default menu (because of template.name == 'page')?
  • Check on both desktop and mobile devices to ensure consistency across all menu layouts.

And there you have it! A really elegant solution to a common need, all thanks to some clever Liquid and the generous help from the Shopify community. This kind of customization truly unlocks the potential of your store, letting you craft a more targeted and effective user journey. Remember, starting with a powerful platform like Shopify makes these advanced customizations not just possible, but relatively straightforward with a little coding savvy. Happy customizing!

Share:

Use cases

Explore use cases

Agencies, store owners, enterprise — find the migration path that fits.

Explore use cases