Fix canonical URL and sitemap trailing slash consistency

This commit is contained in:
Djeex
2026-09-02 20:18:23 +02:00
parent 0b429f5465
commit 940096b2b1
4 changed files with 154 additions and 0 deletions
+18
View File
@@ -34,6 +34,13 @@ export default defineNuxtConfig({
site: {
url: 'https://docu.djeex.fr',
name: 'Docudjeex',
// The build produces a static site (Nitro's default `autoSubfolderIndex`
// writes every route as `path/index.html`), so canonical/og:url/sitemap
// must carry the trailing slash too, matching what's actually on disk.
// Without this, canonical points to the no-slash URL while the static
// host's directory redirect sends visitors (and crawlers) to the slash
// version, creating a redirect loop that keeps pages out of the index.
trailingSlash: true,
},
app: {
head: {
@@ -69,6 +76,17 @@ export default defineNuxtConfig({
},
},
},
// Keeps <NuxtLink> hrefs (including the ones i18n's switchLocalePath
// builds for hreflang) consistent with the trailing-slash URLs enforced
// by app/middleware/trailing-slash.global.ts, so internal navigation
// never triggers that redirect either.
experimental: {
defaults: {
nuxtLink: {
trailingSlash: 'append',
},
},
},
i18n: {
defaultLocale: 'en',
locales: [{