1

I am working on a Magento 2.1.7 shop and I have created a child-theme of Magento Blank.

In the back-end, I have created a block with a custom, hardcoded, navigation like:

<nav>
 <ul>
  <li><a href="http://www.examplewebsite.com/">Home</a></li>
  <li><a href="http://www.examplewebsite.com/about">About</a></li>
  <li><a href="http://www.examplewebsite.com/blog">Blog</a></li>
  <li><a href="http://www.examplewebsite.com/contact">Contact Us</a></li>
 </ul>
</nav>

The question: Is there a piece of code for the website's base URL (a term often used in Codeigniter), so that the code above can be reusable?

0

You need to use {{store url=""}} for get base url of site in static block and pages.

<nav>
 <ul>
  <li><a href="{{store url=""}}">Home</a></li>
  <li><a href="{{store url="about"}}">About</a></li>
  <li><a href="{{store url="blog"}}">Blog</a></li>
  <li><a href="{{store url="contact"}}">Contact Us</a></li>
 </ul>
</nav>
| improve this answer | |
  • Can I use apostrophes: <li><a href="{{store url='about'}}">About</a></li> for better looking code? – Razvan Zamfir Nov 1 '17 at 14:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.