Magento 2 – Get Base URL in Email Template

base-urlemail-templatesmagento2

I've created a custom footer template inside my theme folder app/design/Vendor/Module/Magento_Email/email/footer.html , the problem is i need to get base url inside this html file.

Best Answer

  • You can setup the url using js file.

First of all add mage/url to the list of dependencies. Then add the below function to your js file.

getBaseUrl: function() {
    return url.build('<your_url_path>');
},

Then use the knockout to set href

<a data-bind="attr: { href: getBaseUrl() }">Add Some Text</a>

Then must clear the varnish and browser cache and check

Related Topic