feat: generate static HTML redirect files for old Docusaurus URLs#756
feat: generate static HTML redirect files for old Docusaurus URLs#756viccuad wants to merge 5 commits into
Conversation
20c6107 to
6aef505
Compare
✅ Deploy Preview for docs-kubewarden-io ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
✅ Deploy Preview for docs-kubewarden-io ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
There was a problem hiding this comment.
Pull request overview
This PR replaces Netlify-based redirect rules with generated static HTML meta-refresh redirect files so legacy (Docusaurus-style) URLs continue to work when hosting via GitHub Pages/gh-pages.
Changes:
- Added a Bash script to generate
index.htmlredirect files for legacy paths based on Antora page sources. - Wired redirect generation into the
community-localandcommunity-remoteMakefile targets. - Removed the catch-all redirect rule from
netlify.toml.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
scripts/generate-redirects.sh |
New script that scans Antora pages/ sources and writes static HTML redirect files into the built site output. |
Makefile |
Runs redirect generation after building the site for both local and remote build targets. |
netlify.toml |
Removes the previous Netlify /* redirect configuration. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| ./scripts/generate-redirects.sh \ | ||
| docs/admc/version-1.35/modules/en/pages \ | ||
| build/site \ | ||
| /admc/1.35/en |
|
Ok, having checked, nobody minds (docs team)that we do this. So, i guess we need to look at the Copilot suggestion and some testing, then all good. @viccuad have I got this right. This runs, it will always generate the same set of links, always to 1.35. So frozen in time? |
Yes, that's the idea, old links will always point to 1.35. I will tackle the Copilot suggestions. |
Add scripts/generate-redirects.sh, which creates meta-refresh HTML files at old flat paths (e.g. /reference/threat-model/index.html) pointing to the new Antora URL structure (/admc/1.35/en/...). Wire into both `make community-remote` and `make community-local` targets so GitHub Pages serves the redirects without needing server-side configuration. Signed-off-by: Víctor Cuadrado Juan <vcuadradojuan@suse.de>
Signed-off-by: Víctor Cuadrado Juan <vcuadradojuan@suse.de>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Signed-off-by: Víctor Cuadrado Juan <2196685+viccuad@users.noreply.github.com>
Generate redirects by scanning the HTML files Antora produced under the antora prefix in the built site, rather than the local .adoc source tree. This ensures the redirect list always matches the actual build output, regardless of which branch or remote Antora pulled content from. Also drop the now-unnecessary PAGES_DIR argument from generate-redirects.sh Signed-off-by: Víctor Cuadrado Juan <vcuadradojuan@suse.de>
e32b737 to
305178a
Compare
|
rebased on top of main to obtain the new |
Signed-off-by: Víctor Cuadrado Juan <vcuadradojuan@suse.de>
|
Blocked on #761. |
Description
This PR removes the Netlify redirect configuration and moves to have static files that redirect.
This allows us to keep serving the page with gh-pages.
Add scripts/generate-redirects.sh, which creates meta-refresh HTML files at old
flat paths (e.g. /reference/threat-model/index.html) pointing to the new
Antora URL structure (/admc/1.35/en/...).
Wire into both
make community-remoteandmake community-localtargets so GitHub Pages serves the redirects without needing server-side
configuration.
Remove unneeded Netlify configuration for redirects.
Test
<netlify-preview>/admc/1.35/en/reference/threat-model.html, file exists, served directly<netlify-preview>/reference/threat-model, no file, redirected to /admc/1.35/en/reference/threat-model, Netlify then serves/admc/1.35/en/reference/threat-model.html`<netlify-preview>/admc/, file/directory exists, served directlyAdditional Information
On build, it creates the folder and file structure with html files, so one can hit the redirects:
This means that we cannot re-use a path like
build-local-community/site/howtosorbuild-local-community/site/introduction, but that's always the case with redirects.Tradeoff
Potential improvement
Checklist