Create dynamically a sitemap of two websites

Hi all,
I have my website organized as followed:
/ > my site made by simple html - not using hugo. It changes rarely.
/blog > the blog made using hugo . this creates automatically the sitemap.xml

/ and blog are two differents websites - I made them fitting one inside the other one using _redirects following some posts in this forum succesfully.

How can I create a sitemap.xml including the whole main website each time I deploy the hugo websites?

Thank you :slight_smile:

That’s not something Hugo can do. Hugo is not able to create a sitemap for another cms or site as far as I know.

The only things I can think of are as follows:

You can generate a sitemap in json instead of xml from /
You can load this sitemap as json in the /data directory and as .Site.Data.json etc.
Then you can have hugo parse this, and generate a custom xml that includes the data from your / sitemap and hugo site structure. That would go into your rss template in hugo.

Other than that, you can also merge the two files.
For /, you can use something in your site source like this, and before you generate your / sitemap, read the hugo /blog sitemap and merge the two xml files?

I don’t know what else you can do. Maybe someone else does.

It looks like to creating a JSON sitemap isn’t common at all, do you have any template I can write on my sitetree?

About the entire process, have you ever read anything about how to do the whole thing?

As you could easily guess I’m setting my first steps into hugo world and I’m a bit confused about the whole thing…it’s already a miracle I got my sites working :smiley:

Hugo has a buildin sitemap - if not disabled in your theme

activate the sitemap for home and sections in your config

my top sitemap looks like

<?xml version="1.0" encoding="utf-8" ?>
<sitemapindex xmlns="">

You find my templates here

This looks a perfect solution to me!

In this way I can have a static sitemap.xml to be updated once in a while when I update the main site and one dynamic that is going to be updated each time a deploy again and again!

Thank you!

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.