From c965656cb5c44d318766d45d90729c9ad9b339b2 Mon Sep 17 00:00:00 2001 From: tiennm99 Date: Sun, 4 Oct 2026 11:03:20 +0700 Subject: [PATCH] feat(redirects): send old Stack URLs to their tsuki URLs Generate a Cloudflare Pages _redirects file with 301s from the old /post/YYYY/MM/DD/ post URLs and the old pagination pages. The rules are temporary and marked for removal once the old URLs stop getting traffic. --- config/_default/hugo.yml | 18 ++++++++++++++++++ layouts/home.redirects | 22 ++++++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 layouts/home.redirects diff --git a/config/_default/hugo.yml b/config/_default/hugo.yml index ba2ce07..fde5f9f 100644 --- a/config/_default/hugo.yml +++ b/config/_default/hugo.yml @@ -7,3 +7,21 @@ hasCJKLanguage: false enableRobotsTXT: true timeZone: Asia/Ho_Chi_Minh enableGitInfo: true + +# TEMPORARY (added 2026-10-04): Cloudflare Pages `_redirects` file that sends +# the old Stack-theme URLs (/post/YYYY/MM/DD/, home pagination /page/N/) to +# their tsuki URLs. Remove this block and layouts/home.redirects together once +# the old URLs no longer get traffic (review at 3, 6 or 12 months after the +# migration ships). +mediaTypes: + text/redirects: + delimiter: "" + suffixes: [""] +outputFormats: + redirects: + baseName: _redirects + mediaType: text/redirects + isPlainText: true + notAlternative: true +outputs: + home: [html, rss, redirects] diff --git a/layouts/home.redirects b/layouts/home.redirects new file mode 100644 index 0000000..5ad1761 --- /dev/null +++ b/layouts/home.redirects @@ -0,0 +1,22 @@ +{{- /* + TEMPORARY (added 2026-10-04): 301 redirects from the old Stack-theme URLs to + the tsuki URLs, written to public/_redirects for Cloudflare Pages. + Delete this file and the matching block in config/_default/hugo.yml once the + old URLs no longer get traffic (review at 3, 6 or 12 months after the + migration ships). + + - Posts: Stack had no post permalink rule, so a post lived at its content + path, /post/YYYY/MM/DD/. tsuki serves it at /p/:slug/. + - Pagination: Stack paginated lists with 5 entries per page. The home page + pages (/page/N/) go to /, since tsuki's home page is not paginated, and the + page section's pages (/page/page/N/) go to its first page, /page/. +*/ -}} +{{- $posts := where site.RegularPages "Section" "post" -}} +{{- range $posts }} +/{{ .File.Dir }} {{ .RelPermalink }} 301 +{{- end }} +{{- /* Page counts of the last Stack build; the old URL set is frozen. */ -}} +{{- range seq 38 }} +/page/{{ . }}/ / 301 +{{- end }} +/page/page/2/ /page/ 301