22

I have a static block in Magento with this content:

<li><a href="#/contacts">Contact Us</a></li>

I would like to replace the # with the site's base url. I want it to retrieve this dynamically.

clockworkgeek
  • 37,650
  • 9
  • 89
  • 127
a1anm
  • 1,617
  • 11
  • 45
  • 78

6 Answers6

67

Try adding this to your static block:

<a href="{{store url=""}}">Link to Base URL</a>

That should create a link to your store's base URL.

pix0r
  • 31,139
  • 18
  • 86
  • 102
19

you can use this {{store direct_url="contacts"}}

For example:

<a href="{{store direct_url="contacts"}}">contact us</a>
akjoshi
  • 15,374
  • 13
  • 103
  • 121
Mario
  • 191
  • 1
  • 2
9

For those that are still looking for a solution, the following should do the trick for you...

For the unsecured base URL:

{{config path='web/unsecure/base_url'}}

Or for the secured base URL:

{{config path='web/secure/base_url'}}
JamesD
  • 147
  • 1
  • 5
  • this doesn't include store code (if in url) and `{{store url=""}}` uses safe or unsafe url automagically – PvdL Mar 21 '17 at 12:38
1

Try this

<a href="{{store url="contacts"}}">Contact Us</a>
Naveenbos
  • 2,532
  • 3
  • 34
  • 60
1

You can add store URL in static block:

<a href="{{store direct_url='identifier'}}">Your link</a>
0

A bit more clear and practical scenario (for all level of users) would be: Suppose, we have added a static-block in footer-area/elsewhere. In that static-block we have words like this: Contact Us And we want to add a cms-page link of that words(Contact Us).

Nice and simple way with elaborated steps:

Step-1: Create a page through CMS>Pages. In 'Page Information' Tab section we set URL Key* page-contact-us Necessary Text can be written through the content tab area.

Step-2: After opening up our Static-block through CMS>Static Blocks, we have to write the code like this way:

<a href="{{store url="page-contact-us"}}">Contact Us</a>

That's all, the Base URL of that Static-block is now activated and can be retrieved dynamically.

perfectionist1
  • 857
  • 2
  • 11
  • 14