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.
This commit is contained in:
tiennm99 committed 2026-10-04 11:03:20 +07:00
1 parent 143b6a7bf9
commit c965656cb5
2 files changed
+40

No files matched your search

+18
View File
@@ -7,3 +7,21 @@ hasCJKLanguage: false
enableRobotsTXT: true enableRobotsTXT: true
timeZone: Asia/Ho_Chi_Minh timeZone: Asia/Ho_Chi_Minh
enableGitInfo: true 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]
+22
View File
@@ -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