• Live group demo of Marketing Hub + Data Agent

    Standardize reporting, reduce manual work, and introduce AI without cleanup

    Join us on March 12
  • Marketing that's efficient and human? That's Loop Marketing.

    Explore HubSpot Academy's 39-video playlist and put it into practice.

    Start learning

Hubl variable for website root url

NPeters
Contributor

I have a header that contains a logo that when clicked takes you to the homepage.

 

The homepage is a root url ie http://www.mywebsite.com

 

I had expected as with other CMSs that there would a simple variable like {{ site_url }}

 

I have looked at the variable docs. There appears to be nothing. I had tried {{ group.absolute_url }} nothing as expected.

 

I would rather not hardcode the value.

 

What is the correct HubL way to achieve this.

 

Thanks

3 Accepted solutions
Teun
Solution
Recognized Expert | Elite Partner
Recognized Expert | Elite Partner

@NPeters I created a quick snippet to try. When using request.full_url combined with request.path you could retrieve the domain URL:

<section class="o-container">
  <br /><strong>request.full_url:</strong> {{request.full_url}}<br />
  <strong>request.path:</strong> {{request.path}}<br />
  <strong>filtered url:</strong> {{request.full_url|replace(request.path, '')}}
</section>

 



Learn more about HubSpot by following me on LinkedIn or YouTube

Did my answer solve your issue? Help the community by marking it as the solution.


View solution in original post

webdew
Solution
Guide

Hi @NPeters ,

In the Hubspot module, we have the option for logo settings. you can use this module on your website. and can change the logo redirections and set the default also.

https://developers.hubspot.com/docs/cms/building-blocks/modules/default-modules


Hope this helps!


If we were able to answer your query, kindly help the community by marking it as a solution.

Thanks and Regards. 

View solution in original post

0 Upvotes
gunnarnormand
Solution
Member

Great solution, I'd tweak this slightly so that it works on your homepage:

<a href="{% if request.path == "/" %}
{{ request.full_url }}
{% else %}
{{ request.full_url|replace(request.path, '') }}
{% endif %}">
  <img class="logo">
</a>

Otherwise you would end up with http://www.mywebsite.com/mywebsite.com

View solution in original post

4 Replies 4
webdew
Solution
Guide

Hi @NPeters ,

In the Hubspot module, we have the option for logo settings. you can use this module on your website. and can change the logo redirections and set the default also.

https://developers.hubspot.com/docs/cms/building-blocks/modules/default-modules


Hope this helps!


If we were able to answer your query, kindly help the community by marking it as a solution.

Thanks and Regards. 

0 Upvotes
Teun
Recognized Expert | Elite Partner
Recognized Expert | Elite Partner

Hi @NPeters , you could try using company_domain as described in the documentation. It prints the value set in Website > Pages > Branding > Logo Link.
If that does not give the expected result, you could use group.absolute_url or content.absolute_url and use a filter to strip everything after the domain URL.

What is the usecase for retrieving the homepage URL? You could also use a link field in a global module and set it to the homepage. This is what we do for all the headers we create that include the logo of the website.



Learn more about HubSpot by following me on LinkedIn or YouTube

Did my answer solve your issue? Help the community by marking it as the solution.


Teun
Solution
Recognized Expert | Elite Partner
Recognized Expert | Elite Partner

@NPeters I created a quick snippet to try. When using request.full_url combined with request.path you could retrieve the domain URL:

<section class="o-container">
  <br /><strong>request.full_url:</strong> {{request.full_url}}<br />
  <strong>request.path:</strong> {{request.path}}<br />
  <strong>filtered url:</strong> {{request.full_url|replace(request.path, '')}}
</section>

 



Learn more about HubSpot by following me on LinkedIn or YouTube

Did my answer solve your issue? Help the community by marking it as the solution.


gunnarnormand
Solution
Member

Great solution, I'd tweak this slightly so that it works on your homepage:

<a href="{% if request.path == "/" %}
{{ request.full_url }}
{% else %}
{{ request.full_url|replace(request.path, '') }}
{% endif %}">
  <img class="logo">
</a>

Otherwise you would end up with http://www.mywebsite.com/mywebsite.com