How to create a second, different sitemap

I’m in the process of migrating to hugo. I have successfully configured/amended the sitemap.xml template to produce the sitemap.

What I now want to do is produce a second sitemap “/videositemap.xml”. (Its purpose is obvious).

My fist step would be to duplicate the default “sitemap.xml” file as videositemap.xml and then somehow when building the site have that processed producing the output to /videositemap.xml (from there I could make the changes to the template that I would need to make)

I have experimented with additional output formats in config.toml and in the frontmatter of / but really not gotten anywhere useful - and I am finding the existing documentation a bit sparse.

Any advice on how I can do this would be gratefully received, including but not limited to links to further material / reading that’ll get me there in hugo world.


I wrote a tip about making a custom sitemap.

I think you would just need to alter the range statement in the sitemap template there, to filter on your video posts.

Hi Rick. Thank you for your reply. Yours was one of the posts I had read before asking my question. Unless I am reading it wrongly or misunderstand it (which is very possible I admit) your post tells me to edit the sitemap.xml - and I could do that - but that would not make a second output document - merely would change the current sitemap.xml output. I am happy with the sitemap.xml I can create - I just want to create a second different one at the same time with a different output file.

I haven’t tried making a second one but, can you just copy it to a different name so you have both sitemap.xml and whatever.xml? Does that work?

That’s where I started - but when I duplicated sitemap.xml as videositemap.xml I get nothing - no output file at all.

The hints would be here I think:

I don’t have time to experiment today but, I think it’s a matter of getting your second sitemap template put in the right place and named right. Not sure, but you might need to make a dummy and put an “outputs” in its frontmatter to trigger use of that template.

Thanks. Yes I did try to work my way through that before too and again now. But the examples are cryptic. I tried frontmatter as:

    baseName = "videositemap"
    isPlainText = false
    mediaType = "application/xml"
    protocol = "xml://"
    path = "/videositemap.xml"

But no output. Tried creating a videositemap.xml file also to no effect.

I’m sure your right, the clues are there that it is possible. But I haven’t, after hours of messing about, gotten anywhere useful with it.

My only success if you could call it that is by pasting their example into my config.toml I got a page created called index.xml.

I suspect this is mentioned in the docs, but you need a outputFormats definition (you got that covered) + a template (below /layouts) and then you need to tell Hugo when to use it (outputs).

Thanks - I am missing a bit for sure.
Just to check them.
output formats definition in config.toml? ok
template below layouts? ok
where’s the bit where I tell hugo to use it? A link please?
Also which bit of config tell hugo the name of the template to use?

Thanks for your help.



I have added an outputs config and some progress is being made. However work commitments have stopped me going through it properly so I will report back after I have had a solid hack at it. I think I’ll try doing this on a clean hugo setup first too. Thanks again.


I’m sure there’s something fundamental that I am not getting. Been hacking at this for another hour. Currently no output is generated from
config.toml as:

emphasized text [mediaTypes.“videositemap/xml”]
suffixes = [“xml”]

baseName = “videositemap”
isPlainText = false
mediaType = “videositemap/xml”
protocol = “xml://”
path = “/”

page = [“HTML”, “videositemap”]
section = [“HTML”, “videositemap”]
blog = [“HTML”, “videositemap”]
gallery = [“HTML”, “videositemap”]

with a template file under layouts/default/videositemap.xml . (also tried html) too.

BTW: The online documentation for mediatypes is outdated and generates an error for using “suffix”.

Any help or pointers gratefully received .

Thanks G

Could we see your repo? For example, the above-quoted layouts/default should be layouts/_default.

example for my ATOM feed - change atom to video …

    suffixes              = ["xml"]
    MediaType             = "application/atom+xml"
    BaseName              = "feed"
    suffix                = "xml"
    IsHTML                = false
    IsPlainText           = false
    noUgly                = true
    Rel                   = "alternate"
    home                  = [ "HTML", "ATOM", "JSON"]

You missed the home entry!

it uses _default/home.atom.xml

Thanks. I did have that wrong and changed it to “_default” - in itself that had no effect. I tried several naming conventions for the videositemap file so the layouts now look like:

… more in re ply to ju52

Thanks ju52. I added a home entry and a home.vidositemap.xml. That produced output (yay!) but it seems only for that one page. Other pages produce nothing so far - and I’m looking to produce one (second) videositemap.xml output file for every page on the site. Not a videositemap.xml for each page - I’m not sure if this gets us in that direction but it is progress of some kind.


Reading the entire alternative output formats section there’s nothing in it to say that that lends itself to the task of producing one new output file from many pages as with a sitemap. Then again it doesn’t say it wont do that either. However I presume that the processing that generates RSS and Sitemaps is “special” somehow.


Righto - I have a solution of sorts. It does not come with the confidence of complete understanding but with the input of your good selves I have achieved what looks like a workable option. So Thanks.

Here’s the pieces:

  1. I have a template file _default/home.videositemap.xml
  2. In that file I can range over .Data.Pages to get the whole site.
  3. In config.toml I have:
    baseName = "videositemap"
    isPlainText = false
    mediaType = "application/xml"
    protocol = "xml://"
    path = "/"

  home = ["HTML", "videositemap", "RSS"]

And together that produces a file /videositemap.xml

Which is what I wanted.

Thanks for your ideas / help / and pointers Rick & JU52



Using te hugo options –debug --log you can see what partials hugo is searching. It helped me to work out my solution. sitemap and RSS are special children for Hugo, with ATOM I had to research.


Thanks - that sounds useful too.

@gerardv - thanks for your research and writeup. I used the technique described in your post above and added a bit to it because I wanted to cull out any page with a url in the frontmatter. So I copied ./themes/docsy/userguide/layouts/sitemap.xml to layouts/sitemap.xml and added below the Range loop:

      {{ if (not (isset .Params "url")) }}

Worked great to produce a sitemap without those redirect-only pages that specify a url.