Hugo Sitemap: Built-in Generation and Configuration
Hugo generates a sitemap.xml automatically when you run hugo to build your site. No plugins or additional packages are needed. The sitemap is placed in the root of your public/ directory and includes all pages and posts by default. The critical requirement is that your baseURL in hugo.toml (or config.toml) must be set to your production domain - without it, Hugo generates relative URLs which are invalid in sitemaps.
Setting Your baseURL
The trailing slash in baseURL is important - Hugo concatenates paths directly, so without it you get malformed URLs like https://yoursite.comsomepage instead of https://yoursite.com/somepage.
Configuring Sitemap Options
You can override changefreq and priority at the page level by adding them to a page front matter. For example, adding priority = 1.0 to your homepage front matter gives it the highest priority in the sitemap regardless of the global default.
Excluding Pages from the Hugo Sitemap
To exclude a specific page, add sitemap to the page front matter and set disable to true. In YAML front matter: sitemap: disable: true. In TOML front matter: [sitemap] disable = true. For draft pages, Hugo automatically excludes them from the sitemap (drafts are not built in production unless you pass --buildDrafts). For entire sections, you can customize the sitemap template in layouts/sitemap.xml to filter out specific section types.
Common Hugo Sitemap Issues
Sitemap showing localhost URLs: Your baseURL is set to localhost or empty. Always set baseURL to your production URL before deploying. Use environment variables or build flags: HUGO_BASEURL=https://yoursite.com hugo.
Taxonomy pages bloating the sitemap: Hugo includes tag and category pages in the sitemap by default. If you have hundreds of tags, this creates a large number of thin pages in your sitemap. Either noindex taxonomy pages using a custom robots meta in your taxonomy templates, or disable taxonomy sitemap entries in your sitemap template.