diff --git a/astro.config.mjs b/astro.config.mjs index 59f004e..629a00c 100644 --- a/astro.config.mjs +++ b/astro.config.mjs @@ -145,6 +145,10 @@ export default defineConfig({ if (pathname === '/') item.priority = 1.0; const lastmod = lastmodByRoute.get(pathname); if (lastmod) item.lastmod = lastmod; + // Samme kanoniske form som og de interne links: + // uden afsluttende skråstreg. Slås lastmod op FØR strippet, fordi + // lastmodByRoute er nøglet på Astros egne ruter (som har skråstregen). + if (pathname !== '/') item.url = item.url.replace(/\/$/, ''); return item; }, }), diff --git a/src/components/Head.astro b/src/components/Head.astro index 03eb9c5..080d36f 100644 --- a/src/components/Head.astro +++ b/src/components/Head.astro @@ -19,7 +19,11 @@ const { const pageTitle = title ? `${title} · ${SITE.name}` : `${SITE.title} — Datalog & Technical Solution Architect`; const desc = description ?? SITE.description; -const canonical = new URL(Astro.url.pathname, SITE.url).href; +// Kanonisk form er UDEN afsluttende skråstreg. Origin serverer begge former med +// 200, og de interne links peger alle på no-slash — så canonical og sitemap skal +// gøre det samme, ellers opdager Google to adskilte sæt af de samme sider. +const canonicalPath = Astro.url.pathname.replace(/\/$/, '') || '/'; +const canonical = new URL(canonicalPath, SITE.url).href; const ogImage = new URL(image ?? '/og.png', SITE.url).href; const graphs = [baseGraph, ...jsonLd]; --- diff --git a/src/pages/rss.xml.js b/src/pages/rss.xml.js index a1946e4..81b9b26 100644 --- a/src/pages/rss.xml.js +++ b/src/pages/rss.xml.js @@ -9,11 +9,14 @@ export async function GET(context) { title: SITE.title, description: SITE.description, site: context.site, + // Samme kanoniske URL-form som canonical og sitemap: uden afsluttende + // skråstreg. @astrojs/rss tilføjer den ellers selv (default true). + trailingSlash: false, items: posts.map((p) => ({ title: p.data.title, description: p.data.description, pubDate: p.data.date, - link: `/blog/${p.id}/`, + link: `/blog/${p.id}`, })), customData: `da-dk`, });