Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Magento Store - Get Base URL in Static Block

Tags:

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.

like image 577
a1anm Avatar asked Jan 05 '10 21:01

a1anm


People also ask

How do I get the base URL in Magento 2 CMS block?

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. That's all, the Base URL of that Static-block is now activated and can be retrieved dynamically.

How can get current URL in Magento?

If you need to get current URL in Magento 2 PHTML file the easiest way to do this is to use the following code: $currentUrl = $block->getUrl('*/*/*', ['_current' => true, '_use_rewrite' => true]); This is the best method since you don't even need to use the Object Manager.

What is Magento Base URL?

Base URL — http://www.yourdomain.com/magento/ Secure Base URL — https://www.yourdomain.com/magento/


2 Answers

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.

like image 136
pix0r Avatar answered Sep 20 '22 02:09

pix0r


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

For example:

<a href="{{store direct_url="contacts"}}">contact us</a> 
like image 30
Mario Avatar answered Sep 23 '22 02:09

Mario