seo: enforce trailing slash on all URLs
Deploy / verify (push) Successful in 37s
Deploy / deploy (push) Successful in 55s

- Set trailingSlash='always' globally via root layout.
- Update postHref, pageHref, Pagination, tag/breadcrumb hrefs, blog→posts
  redirects to emit trailing slash.
- Match old Astro canonical so indexed URLs hit 200 directly instead of
  308-redirect.
This commit is contained in:
Peter Meier
2026-04-17 22:23:16 +02:00
parent d28a55a70a
commit f328989aa8
12 changed files with 24 additions and 19 deletions
+1 -1
View File
@@ -25,7 +25,7 @@ export type SearchHit = {
function pageHref(p: { slug?: string; _slug?: string }): string {
const raw = (p.slug ?? p._slug ?? '').replace(/^\//, '').trim();
if (!raw || raw === 'home') return '/';
return '/' + raw.split('/').filter(Boolean).map(encodeURIComponent).join('/');
return '/' + raw.split('/').filter(Boolean).map(encodeURIComponent).join('/') + '/';
}
export const GET: RequestHandler = async () => {