Search code examples
magentotagsanchor

Magento Anchor Tags


I have a list of FAQ links on my home page in a static block in the footer. Each link however just opens up the FAQ page.

My code sample

<a href="{{store url="faqs#1"}}">What is Individually Quick Frozen?</a></li>

What I want is that when a user clicks a particular link in the list on the homepage footer under FAQs (as above), the user should be directly be taken to the answer of that question on the FAQ page i.e. the page should scroll down to where the questions is answered.

My Code sample

<p><strong><a id="1">What is Individually Quick Frozen?</a></strong></p>

But no joy! what am I doing wrong?


Solution

  • Make your link look like this:

    <a href="{{store url="faqs"}}#_1">What is Individually Quick Frozen?</a></li>
    

    or better yet

     <a href="{{store direct_url="faqs"}}">What is Individually Quick Frozen?</a></li>
    

    Note: For Cms pages urls use direct_url as a parameter for the {{store}} directive. It avoids having a / at the end of the URL. Useful if your pages end with .html. It's not your case but it may be useful in the future.

    Now your code in the cms page should looks like this:

    <p><strong><a id="_1">What is Individually Quick Frozen?</a></strong></p>
    

    Avoid using numerical ids for elements. It's not standard