Hi!
my website uses swedish and english languages and im wondering how i can add hreflang attribute and lang attribute in hubspot?
i got to know that you add hreflang attribute in head tag and lang in html tag but im wondering how i should add it in hubspot.
thanks!
Hi @AMehdi3 the best way to manage languages in HubSpot would be to set your primary language for the domain:
And for your second language, you would create multi-variant versions for the pages in that language which will automatically update the language attributes and URL.
yes but i got warning from semrush that my website were missing hreflang and lang attributes. their solution showed that you can add lang=en in html tag and <link rel=“alternate” hreflang=“en” href=“https://example.com” /> in head tag.
i do have primary language set in my hubspot etc. but i think i should maybe add lang and hreflang attributes.
the solution i have so far is to add
<html lang=“{{ html_lang }}”>
in html tag and
{% set href_plain = ‘//’ ~ request.domain ~ ‘/’ %}
<link rel=“alternate” hreflang=“en” href=“{{ href_plain }}” />
<link rel=“alternate” hreflang=“sv” href=“{{ href_plain }}/sv” />
in head tag. i havent used these solutions yet since i want to be sure its correct one
@AMehdi3 no problem, if you’d like to add the hreflang and lang attributes to resolve the semrush warning, you can add it to the Site Header HTML and you should be all set.
@Jnix284 yes but is this the right solution i should add?
where i said:
"the solution i have so far is to add
<html lang=“{{ html_lang }}”>
in html tag and
{% set href_plain = ‘//’ ~ request.domain ~ ‘/’ %}
<link rel=“alternate” hreflang=“en” href=“{{ href_plain }}” />
<link rel=“alternate” hreflang=“sv” href=“{{ href_plain }}/sv” />"
is it the right solution? or do i need to change these codes? these solution is where i found by myself and i would like to confirm if it is correct one.
thanks!
@AMehdi3 yes, your code looks correct - I would recommend adding it, then verifying a sample of your pages for each language via the chrome developer console, and then recheck the warning in SEMrush to make sure it’s resolved.