Skip to content

Fix 404 on blog navigation links to flat-export Next.js pages#72

Merged
abinav2307 merged 1 commit intodocumentdb:mainfrom
guanzhousongmicrosoft:fix/blog-nav-trailing-slash-404
Apr 29, 2026
Merged

Fix 404 on blog navigation links to flat-export Next.js pages#72
abinav2307 merged 1 commit intodocumentdb:mainfrom
guanzhousongmicrosoft:fix/blog-nav-trailing-slash-404

Conversation

@guanzhousongmicrosoft
Copy link
Copy Markdown
Contributor

Problem

Navigation links from the blog (/blogs/ and /blogs/posts/...) back to the K8s Operator, Docs, and Download pages return 404 in production.

Reproduction (live):

Root cause

blogs/_layouts/default.html builds the nav with trailing slashes:

{% assign docs_href = site_root | append: '/docs/' ... %}
{% assign packages_href = site_root | append: '/packages/' ... %}
{% assign operator_href = site_root | append: '/kubernetes-operator/' ... %}

But the Next.js static export (output: "export") emits flat HTML files at out/docs.html, out/packages.html, out/kubernetes-operator.html with no {route}/index.html counterpart. GitHub Pages serves those at /docs, /packages, /kubernetes-operator only; the trailing-slash variants look for /{route}/index.html and 404.

Every other internal link in the repo (Next.js pages, articles markdown, the /blogs/ self-link, etc.) already uses the no-trailing-slash convention, so this layout was the sole offender.

Fix

Drop the trailing slash from the three offending hrefs. home_href (/) and blogs_href (/blogs/) keep their slash because they resolve to real index.html files (out/index.html, out/blogs/index.html).

Verification

Rebuilt the Jekyll blog with both deployment baseurls and confirmed the generated nav now points to existing files.

Local (--baseurl /blogs):

href="/"
href="/blogs/"
href="/docs"
href="/kubernetes-operator"
href="/packages"

CI deployment (--baseurl /documentdb.github.io/blogs):

href="/documentdb.github.io/"
href="/documentdb.github.io/blogs/"
href="/documentdb.github.io/docs"
href="/documentdb.github.io/kubernetes-operator"
href="/documentdb.github.io/packages"

All resolve to existing files in the out/ artifact.

Verified with a wider audit that no other Jekyll templates, Next.js pages, or markdown content emit internal links with trailing slashes to flat-export routes.

The Jekyll blog layout generated nav links with trailing slashes
(/kubernetes-operator/, /docs/, /packages/), but the Next.js static
export produces flat HTML files (/kubernetes-operator.html, /docs.html,
/packages.html). GitHub Pages serves those at /kubernetes-operator,
/docs, /packages with no trailing slash; the trailing-slash variants
look for an index.html that does not exist and return 404.

Drop the trailing slash from the K8s Operator, Docs, and Download
hrefs in blogs/_layouts/default.html so the blog navigation matches
the routes the Next.js export actually serves. Home (/) and Blogs
(/blogs/) keep their trailing slash because they resolve to real
index.html files.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: Guanzhou Song <guanzhousong@microsoft.com>
@abinav2307 abinav2307 merged commit 64e020c into documentdb:main Apr 29, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants