Fix Your Sitemap for Hugo

Updated April 2026·By SitemapFixer Team

Hugo ships a default sitemap.xml template, but taxonomies, section pages, future-dated posts, and multilingual mounts quickly create a sitemap that doesn't match what you actually want indexed.

Analyze your Hugo sitemap nowTry Sitemap Fixer Free

Hugo's sitemap gets it mostly right by default, but "mostly right" includes every taxonomy term page, every pagination URL, and sometimes drafts. The fix is template-level: override layouts/sitemap.xml and filter what gets emitted.

Reviewed a Hugo docs site last month. 420 content pages, 1,800 URLs in the sitemap. The padding was every tag page (290), every author page (14), and every pagination URL for the blog section (/blog/page/2 through /blog/page/47). A 20-line template override cut the sitemap to 435 URLs.

Common Hugo Sitemap Issues

hugo.toml sitemap config

baseURL = 'https://example.com/'
enableGitInfo = true
disableKinds = ['taxonomy', 'term']  # drop tag/category list pages

[sitemap]
  changefreq = 'weekly'
  filename = 'sitemap.xml'
  priority = 0.5

[languages]
  [languages.en]
    weight = 1
    languageName = 'English'
    contentDir = 'content/en'
  [languages.de]
    weight = 2
    languageName = 'Deutsch'
    contentDir = 'content/de'

defaultContentLanguage = 'en'

Custom layouts/sitemap.xml

<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
        xmlns:xhtml="http://www.w3.org/1999/xhtml">
  {{ range where .Data.Pages "Params.sitemap_exclude" "ne" true }}
    {{ if not (in .RelPermalink "/page/") }}
      <url>
        <loc>{{ .Permalink }}</loc>
        {{ if not .Lastmod.IsZero }}
          <lastmod>{{ safeHTML (.Lastmod.Format "2006-01-02T15:04:05-07:00") }}</lastmod>
        {{ end }}
        {{ with .Sitemap.ChangeFreq }}
          <changefreq>{{ . }}</changefreq>
        {{ end }}
        {{ if ge .Sitemap.Priority 0.0 }}
          <priority>{{ .Sitemap.Priority }}</priority>
        {{ end }}
        {{ if .IsTranslated }}
          {{ range .AllTranslations }}
            <xhtml:link rel="alternate" hreflang="{{ .Lang }}" href="{{ .Permalink }}"/>
          {{ end }}
        {{ end }}
      </url>
    {{ end }}
  {{ end }}
</urlset>

This version skips anything with sitemap_exclude: true in front matter and any pagination URL. The xhtml:link block emits hreflang alternates for translated content.

Multilingual sitemap index

With multiple languages configured, Hugo generates /en/sitemap.xml, /de/sitemap.xml, etc. Add a layouts/sitemapindex.xml template so you have a single URL to submit to Google Search Console. Some Hugo versions need an explicit output format declaration in hugo.toml under [outputs] to actually render the index - check with hugo list --output if the file isn't appearing in public/.

Deployment pipeline notes

Production builds should be plain hugo or hugo --minify. Never ship with --buildDrafts or --buildFuture - that's how draft posts leak into live sitemaps. If you use a preview environment, put it on a separate domain with its own robots.txt that blocks everything. Netlify and Vercel preview deploys are usually fine because the preview URL is randomized and not linked to your production domain.

Step-by-Step Fix Guide

  1. Set enableGitInfo = true in hugo.toml so .Lastmod reflects actual commit times
  2. Disable unused kinds (disableKinds = ['taxonomy', 'term']) if tag/category pages shouldn't exist
  3. Create layouts/sitemap.xml and filter on sitemap_exclude and pagination URLs
  4. Add sitemap_exclude: true to thank-you pages, legal notices, and any near-duplicate landing pages
  5. Never run --buildDrafts or --buildFuture in production
  6. For multilingual, set [languages] with weight and defaultContentLanguage, and add layouts/sitemapindex.xml
  7. Deploy, verify with curl https://yourdomain.com/sitemap.xml | grep -c "<url>"
  8. Submit to Google Search Console and monitor coverage

Frequently Asked Questions

Where is Hugo's default sitemap template?
It's embedded in the Hugo binary and outputs /sitemap.xml. Override it by creating layouts/sitemap.xml in your project. For multilingual sites, add layouts/sitemapindex.xml for the index file.
Why are _index.md pages missing from my Hugo sitemap?
They're included by default - you might be excluding them by accident. Check that your custom sitemap template doesn't filter on .Kind and confirm the section page has no draft: true or sitemap_exclude: true in front matter.
How do I handle multilingual sitemaps in Hugo?
Hugo generates one sitemap per language when you enable [languages] config. Ship a sitemapindex.xml template that references each /en/sitemap.xml, /de/sitemap.xml, etc., and submit the index to Google Search Console.
Analyze your Hugo sitemap
Find all issues in your sitemap - free, no credit card needed
Analyze My Sitemap Free
Other platform guides