Setting navigation highlight for active view template

New Member
1 0 0

I'm customizing the customer account template for a client, and have split it include multiple views based on this guide: How to Use Alternate Templates in Shopify Theme Development (skip down to the "Switch templates via the URL" section at the bottom of the article).


I built out navigation with a menu set with relative URLs targeting my custom views, e.g. /account?view=orders, /account?view=rewards. Now I'm trying to set an active state in the menu to highlight the current page/view the user is on, i.e. highlight "Rewards" when on the rewards view (customers/account.rewards.liquid).


Link.current returns true for the link targeting the customers/account.liquid template, but false for any of the view templates, e.g. customers/account.orders.liquid, customers/account.rewards.liquid.


Any ideas for how to determine if a navigation link matches the currently displaying view?


Thanks for any suggestions, I appreciate it!