Skip to content

Render Netlify redirects from page aliases #53396

@lmktfy

Description

@lmktfy

This is a Feature Request

What would you like to be added
Update layouts/index.redirects to support Hugo aliases (in the page front matter). After the change, we would implement Hugo aliases by rendering them to Netlify redirects.

Why is this needed
If we do this, we can automate more of how redirects work.

  • [We can make it so that] localizations can manage their own redirects, provided that source and target are both within that localized page
  • We can automatically handle certain redirects from English to localized pages, so that for example redirecting /xx/docs/ to /xx/docs/home/ is automatic
  • it becomes easier to check redirects at site build time and warn when we have found one that redirects to a missing page
  • it becomes much easier to reject a change where a localization team accidentally add an alias where an English page redirects to a localized page

(aside) If we want to, we have the option to support a different mechanism (think <meta http-equiv="refresh" content="0;url=http://localhost:1313/example" />) for local previews. Automating even that choice is feasible.

Comments
See https://honnef.co/articles/generating-netlify-_redirects-from-hugo/ for a basic implementation.

Ours needs to cover:

  • per-localization aliases
  • checks; for example, a French page shouldn't be able to say that it is an alias for /ko/docs/home/ (instead, that'd be a build error)
  • the existing automation for redirecting to the latest API version

Edit Also see #53396 (comment)

/area web-development

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/web-developmentIssues or PRs related to the kubernetes.io's infrastructure, design, or build processeskind/featureCategorizes issue or PR as related to a new feature.triage/acceptedIndicates an issue or PR is ready to be actively worked on.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions