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

0 Upvotes
3 Replies 3
Teun
Guide | Diamond 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.

Did my answer solve your issue? Help the community by marking it as the solution.
Teun
Guide | Diamond 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>

 

Did my answer solve your issue? Help the community by marking it as the solution.
0 Upvotes
webdew
Top Contributor | Diamond Partner

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