# Sitemap in single language website with /en prefix

**URL:** <https://discourse.gohugo.io/t/sitemap-in-single-language-website-with-en-prefix/48861>\
**Category:** support\
**Created:** [March 15, 2024, 6:51pm UTC](https://discourse.gohugo.io/t/sitemap-in-single-language-website-with-en-prefix/48861 "2024-03-15T18:51:20Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![jmichelgarcia](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/jmichelgarcia/32/17691_2.png) [@jmichelgarcia](https://discourse.gohugo.io/u/jmichelgarcia)\
**Post date:** [March 15, 2024, 6:51pm UTC](https://discourse.gohugo.io/t/sitemap-in-single-language-website-with-en-prefix/48861/1 "2024-03-15T18:51:20Z")

</div>

Follow-up of: [Force lang prefix (en) with only one language?](https://discourse.gohugo.io/t/force-lang-prefix-en-with-only-one-language/40390)

I have recently being able to force the `/en` path for a single language website, with the below configuration (this is probably some recent hugo enhancement, either intentional, or unintentional):

```auto
defaultContentLanguageInSubdir = true
defaultContentLanguage = "en"

[languages]
[languages.en]
languageName = "English"
staticDir = "static"
contentDir = "content/en"

```

Everything works, aside from the sitemap which keeps generating the wrong sitemap.

```auto
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<sitemap>
<loc>//localhost:1313/sitemap.xml</loc>
<lastmod>2024-03-15T13:15:11-04:00</lastmod>
</sitemap>
</sitemapindex>

```

It should be `//localhost:1313/en/sitemap.xml` instead of `//localhost:1313/sitemap.xml`

This is due to this line I believe: [hugo/hugolib/site.go at d4d49e0f0ec53ef7e105c51b5c6fd198c86acb7e · gohugoio/hugo · GitHub](https://github.com/gohugoio/hugo/blob/d4d49e0f0ec53ef7e105c51b5c6fd198c86acb7e/hugolib/site.go#L604)

```auto
func (s *Site) HomeAbsURL() string {
	base := ""
	if len(s.conf.Languages) > 1 {
		base = s.Language().Lang
	}
	return s.AbsURL(base, false)
}

```

Is there anything that I can do that do not involve redefining `sitemapindex.xml`?

Is this considered a bug I should report? (I think I may be using Docsy/Hugo) in non recommended ways as per @jmooring comment in [Force lang prefix (en) with only one language?](https://discourse.gohugo.io/t/force-lang-prefix-en-with-only-one-language/40390)

---

<div class="post-metadata">

**Author:** ![jmooring](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/jmooring/32/4214_2.png) [@jmooring](https://discourse.gohugo.io/u/jmooring)\
**Post date:** [March 15, 2024, 7:25pm UTC](https://discourse.gohugo.io/t/sitemap-in-single-language-website-with-en-prefix/48861/2 "2024-03-15T19:25:43Z")

</div>

Yes, this is a bug. This simple configuration:

```plaintext
baseURL = 'https://example.org/'
title = 'Hugo Forum Topic #48861'
disableKinds = ['rss','taxonomy','term']
defaultContentLanguageInSubdir = true

```

With this content:

```plaintext
content/
└── _index.md

```

Is published to:

```plaintext
public/
├── en/
│ ├── index.html
│ └── sitemap.xml
├── index.html
└── sitemap.xml <-- this is a sitemapindex, but it points to itself

```

I’m not sure what the fix is though. Should the sitemapindex point to `https://example.org/en/sitemap.xml`, or should the actual sitemap be moved to the root (replacing sitemap index)?. It seems like the former would be the right thing to do.

---

<div class="post-metadata">

**Author:** ![jmichelgarcia](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/jmichelgarcia/32/17691_2.png) [@jmichelgarcia](https://discourse.gohugo.io/u/jmichelgarcia)\
**Post date:** [March 15, 2024, 7:30pm UTC](https://discourse.gohugo.io/t/sitemap-in-single-language-website-with-en-prefix/48861/3 "2024-03-15T19:30:53Z")

</div>

I think the correct behaviour should be what I see in the docsy example site → [https://example.docsy.dev/sitemap.xml](https://example.docsy.dev/sitemap.xml)

```auto
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
  <sitemap>
    <loc>/en/sitemap.xml</loc>
    <lastmod>2023-11-10T12:40:56+01:00</lastmod>
  </sitemap>
  <sitemap>
    <loc>/fa/sitemap.xml</loc>
    <lastmod>2023-11-10T12:40:56+01:00</lastmod>
  </sitemap>
  <sitemap>
    <loc>/no/sitemap.xml</loc>
    <lastmod>2023-11-10T07:28:51-05:00</lastmod>
  </sitemap>
</sitemapindex>

```

So in your dummy example:

One language neutral `sitemap.xml` (index) at root, that points to a language specific sitemap under `/en/sitemap.xml`

Something like

```auto
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
  <sitemap>
    <loc>/en/sitemap.xml</loc>
    <lastmod>2023-11-10T12:40:56+01:00</lastmod>
  </sitemap>
</sitemapindex>

```

---

<div class="post-metadata">

**Author:** ![jmooring](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/jmooring/32/4214_2.png) [@jmooring](https://discourse.gohugo.io/u/jmooring)\
**Post date:** [March 15, 2024, 7:33pm UTC](https://discourse.gohugo.io/t/sitemap-in-single-language-website-with-en-prefix/48861/4 "2024-03-15T19:33:30Z")

</div>

The embedded template generates absolute URLs, so even if we fix this, you’ll need to override the sitemapindex template to get relative URLs.

I’ll log an issue on this… it isn’t anything new.

---

<div class="post-metadata">

**Author:** ![jmooring](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/jmooring/32/4214_2.png) [@jmooring](https://discourse.gohugo.io/u/jmooring)\
**Post date:** [March 15, 2024, 7:41pm UTC](https://discourse.gohugo.io/t/sitemap-in-single-language-website-with-en-prefix/48861/5 "2024-03-15T19:41:54Z")

</div>

See [https://github.com/gohugoio/hugo/pull/12267](https://github.com/gohugoio/hugo/pull/12267), merged and available in the next release.

---

<div class="post-metadata">

**Author:** ![system](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/system/32/1_2.png) [@system](https://discourse.gohugo.io/u/system)\
**Post date:** [March 17, 2024, 7:42pm UTC](https://discourse.gohugo.io/t/sitemap-in-single-language-website-with-en-prefix/48861/6 "2024-03-17T19:42:11Z")

</div>

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