CMS Development

ATalochka
Member

Hreflang Implementation in sitemap.xml for HubSpot Multilingual Site

SOLVE

Hello, we are localizing our website and need to implement hreflang via sitemap. However, we are not able to edit the sitemap.xml file directly.
Is there a way to:

  1. Add alternate hreflang links via sitemap in HubSpot?

  2. Add a custom sitemap file that includes xhtml:link?

  3. Automatically handle hreflang for multilingual content hosted in subdirectories like /de/?

0 Upvotes
1 Accepted solution
Anton
Solution
Thought Leader | Partner
Thought Leader | Partner

Hreflang Implementation in sitemap.xml for HubSpot Multilingual Site

SOLVE

Hey @ATalochka

since the sitemap.xml is being generated automatically it's unfortunately not possible to modify it. 


Something you might want to look at is your themes base.html (might have a different name) and add your language to it. 

 

Technically it should be possible to create your own sitemap.xml, put it into the file-manager or design-manager and reference it in the base.html with some HubL like

{# File-Manager example #}
{% if content.translated_content.language == "English"%}
   {% set sitemap_url = "path-to-english-sitemap.xml" %}
{% elif content.translated_content.language == "Deutsch" %}
   {% set sitemap_url = "path-to-german-sitemap.xml" %}
{% endif %}

{# Design-Manager example #}
{% if content.translated_content.language == "English"%}
   {% set sitemap_url = get_asset_url("path-to-english-sitemap.xml") %}
{% elif content.translated_content.language == "Deutsch" %}
   {% set sitemap_url = get_asset_url("path-to-german-sitemap.xml") %}
{% endif %}


<link rel="sitemap" type="application/xml" title="Sitemap" href="{{ sitemap_url }}">

 

Please note that this won't replace your DOMAIN.com/sitemap.xml

 

 

best, 

Anton

Anton Bujanowski Signature

View solution in original post

3 Replies 3
FSierraMartin
Member

Hreflang Implementation in sitemap.xml for HubSpot Multilingual Site

SOLVE

I guess I like the old favourites Amazon and Ebay. But most of all I love Sign in with Google that is a border smoother and fastpass hero.

0 Upvotes
Anton
Solution
Thought Leader | Partner
Thought Leader | Partner

Hreflang Implementation in sitemap.xml for HubSpot Multilingual Site

SOLVE

Hey @ATalochka

since the sitemap.xml is being generated automatically it's unfortunately not possible to modify it. 


Something you might want to look at is your themes base.html (might have a different name) and add your language to it. 

 

Technically it should be possible to create your own sitemap.xml, put it into the file-manager or design-manager and reference it in the base.html with some HubL like

{# File-Manager example #}
{% if content.translated_content.language == "English"%}
   {% set sitemap_url = "path-to-english-sitemap.xml" %}
{% elif content.translated_content.language == "Deutsch" %}
   {% set sitemap_url = "path-to-german-sitemap.xml" %}
{% endif %}

{# Design-Manager example #}
{% if content.translated_content.language == "English"%}
   {% set sitemap_url = get_asset_url("path-to-english-sitemap.xml") %}
{% elif content.translated_content.language == "Deutsch" %}
   {% set sitemap_url = get_asset_url("path-to-german-sitemap.xml") %}
{% endif %}


<link rel="sitemap" type="application/xml" title="Sitemap" href="{{ sitemap_url }}">

 

Please note that this won't replace your DOMAIN.com/sitemap.xml

 

 

best, 

Anton

Anton Bujanowski Signature
ArisudanTiwari
Guide | Gold Partner
Guide | Gold Partner

Hreflang Implementation in sitemap.xml for HubSpot Multilingual Site

SOLVE

Hi @ATalochka ,

HubSpot automatically manages hreflang tags for multilingual content, but only in the HTML head of the pages, not in the sitemap.xml, and you can’t upload or customize your own sitemap.


Q1. Can I add hreflang tags via sitemap in HubSpot?
Ans - No, HubSpot doesn’t support custom hreflang entries in its sitemap. Instead, it handles hreflang through <link rel="alternate" hreflang="..."> tags in the HTML <head> of each language version.


Q2. Can I upload my own sitemap with XHTML: link tags?
Ans - No, HubSpot’s sitemap is auto-generated, and you can’t override or upload a custom version.


Q3. Does HubSpot add hreflang tags for subdirectories like /de/?
Ans - Yes, as long as you use HubSpot’s built-in multi-language tools, it will auto-insert the correct hreflang tags in the page <head> for all language variants (e.g., /de/, /fr/, etc.).

Helpful Resources:

If my reply answered your question, please mark it as a solution to make it easier for others to find.


Cheers!

Arisudan Tiwari
HubSpot Advisor



Grazitti