Custom Sitemap Structure

I am attempting to create a custom sitemap structure for a multilingual site. The desired structure is that each language would have one sitemap index, and two sitemaps, and that the default language would be at the root:


├─ /page-sitemap.xml
├─ /post-sitemap.xml


├─ /ja/page-sitemap.xml
├─ /ja/post-sitemap.xml


├─ /es/page-sitemap.xml
├─ /es/post-sitemap.xml


I’m unable to determine the best way to proceed with this level of customization from the docs, though. Can anyone offer some guidance?

NOTE: the generation of the page and post sitemaps is not the problem as I’m able to accomplish this with where queries and if statements.

I don’t know of any way to let Hugo do what you want with the in-built features.


Option 1: You use languages per domain instead of languages per sub-folder. Hugo then should create one sitemap per language (if not, we have a structural problem with the sitemap not being where it should be (the root directory of your website).

Option 2: You create a custom content type sitemaps that will go through the pages normally and then create a single sitemap-index (the “home” of the content type) and multiple sitemaps that are linked in that single index. This is still not what you want, but with clever ranging you can separate the .Translations I think.

In General: Think about maybe using sitemap-languagecode-index.xml instead of a subfolder, because sitemaps typically should reside in the root directory of a website. Not 100% sure about this, but the index should definitely live at root.

:thinking: You can generate as many output formats as you want, including XML. Custom Output Formats | Hugo It requires creating the right templates so it will be a bit time consuming, but doable! I hope it helps.

I ended up disabling the built in sitemap functionality, and using a custom output format. Thank you both for your help!