Skip to content

Conversation

Caesarsage
Copy link
Contributor

@Caesarsage Caesarsage commented Sep 30, 2025

Automates generation of /kubernetes-api/latest/ redirects using Hugo
templates that read from hugo.toml's latest parameter.

Description

Changes:

  • Added layouts/index.redirects template to generate _redirects dynamically
  • Renamed static/_redirects to static/_redirects.base to avoid circular
    dependency (the template reads from the stable source file, while
    Hugo dynamically generates a new output file on each build)
  • Configured _redirects output format in hugo.toml
  • Updated .gitignore to exclude local ./netlify test

How it works:
The template reads the version from hugo.toml, generates the dynamic
"latest" redirects, then includes all static redirects from _redirects.base (prev. _redirects).
The final _redirects file is generated on every build.

preview changes:

https://deploy-preview-52591--kubernetes-io-main-staging.netlify.app/docs/reference/generated/kubernetes-api/latest

Issue

Closes: #51542

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Sep 30, 2025
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign natalisucks for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the sig/docs Categorizes an issue or PR as relevant to SIG Docs. label Sep 30, 2025
@k8s-ci-robot k8s-ci-robot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Sep 30, 2025
Copy link

netlify bot commented Sep 30, 2025

Pull request preview available for checking

Built without sensitive environment variables

Name Link
🔨 Latest commit fae0d92
🔍 Latest deploy log https://app.netlify.com/projects/kubernetes-io-main-staging/deploys/68e4525d14f78a000849d8e7
😎 Deploy Preview https://deploy-preview-52591--kubernetes-io-main-staging.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@lmktfy
Copy link
Contributor

lmktfy commented Sep 30, 2025

/area web-development

@k8s-ci-robot k8s-ci-robot added the area/web-development Issues or PRs related to the kubernetes.io's infrastructure, design, or build processes label Sep 30, 2025
Copy link
Contributor

@lmktfy lmktfy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We shouldn't use a 301 redirect, but apart from that this is basically good to merge.

Comment on lines 10 to 11
/docs/reference/generated/kubernetes-api/latest/ /docs/reference/generated/kubernetes-api/{{ $latest }}/ 301
/docs/reference/generated/kubernetes-api/latest/* /docs/reference/generated/kubernetes-api/{{ $latest }}/:splat 301
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We plan to do releases in the future, so:

Suggested change
/docs/reference/generated/kubernetes-api/latest/ /docs/reference/generated/kubernetes-api/{{ $latest }}/ 301
/docs/reference/generated/kubernetes-api/latest/* /docs/reference/generated/kubernetes-api/{{ $latest }}/:splat 301
/docs/reference/generated/kubernetes-api/latest/ /docs/reference/generated/kubernetes-api/{{ $latest }}/ 307
/docs/reference/generated/kubernetes-api/latest/* /docs/reference/generated/kubernetes-api/{{ $latest }}/:splat 307

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(a 301 would mean "for now, and forever, you can treat
/docs/reference/generated/kubernetes-api/latest/ as redirecting to
/docs/reference/generated/kubernetes-api/1.34/ - not what we want)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you move this file, make sure that any other guidance makes it clear where to find the legacy / static redirects. People might not figure it out otherwise.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @lmktfy
there is currently no guidance referencing the legacy / static redirects but i added comments to explain the new update

@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Sep 30, 2025
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Oct 6, 2025
Copy link
Contributor

@lmktfy lmktfy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Oct 9, 2025
@k8s-ci-robot
Copy link
Contributor

LGTM label has been added.

Git tree hash: eb9e43139f9897747240cc2bd4c89cd92660cc46

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/web-development Issues or PRs related to the kubernetes.io's infrastructure, design, or build processes cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. sig/docs Categorizes an issue or PR as relevant to SIG Docs. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add "latest" link in Kubernetes API docs

3 participants