Forum

Thread tagged as: Question, Problem

How to create custom navigation template for a site with anchors on index page.

Hi,

I have a site where the global nav takes you to 3 anchor links on the homepage and the other links go to separate pages.

I know how to create a perch custom template where I can manually add anchor fields, however I still want to mark links as "selected" if that is where the user is.

so if the address bar is www.domain.com/#about-us then the html should be

<li><a href="#about" class="selected">About Us</a></li>

What would be the cleanest way to query the URL and change the class state, also without interupting the usual dynamic elements?

I haven't pasted the full template as I intend to duplicate the standard item.html as a starting point.

Andrew Cetnarskyj

Andrew Cetnarskyj 0 points

  • 6 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

You'll need to do that client side (with CSS and the :target pseudo selector, probably) as the server doesn't get handed anything after the # in a URL.