Skip to content

Support nav links to a section of a page - #104

Merged
shenxianpeng merged 2 commits into
mainfrom
fix/nav-anchor-links
Sep 24, 2026
Merged

shenxianpeng merged 2 commits into
mainfrom
fix/nav-anchor-links

Conversation

@shenxianpeng

Copy link
Copy Markdown
Member

A nav entry that links to a section of a page is reported as "not found in the documentation files", which fails strict builds:

nav:
  - About: about.md
  - License: about.md#license    # warned, and links to the .md file (404 on the built site)
  - License: about/#license      # works on the built site, but still warned

Fix:

  • When the part before # is a documentation page, the link now points at the page's URL plus the anchor: about/#license, or about.html#license with use_directory_urls: false.
  • Links whose path is the URL of a documentation page (about/#license) are logged at DEBUG level instead of being reported as not found. With use_directory_urls: false that URL doesn't exist, so it is still reported.
  • References to missing pages (missing.md#x) are still reported, and absolute paths keep following validation.nav.absolute_links.

Verified end to end with and without directory URLs: the generated hrefs are correct from the home page, from nested pages, and for anchors on the current page. The anchor itself isn't validated against the target page; that would have to happen after rendering.

The nav section of the configuration docs now shows how to link to a section of a page.

Related Issue

No issue in this repository.

Checklist

  • New tests added for new behavior (if applicable)
  • Documentation updated (if applicable)
  • Release notes docs/about/release-notes.md updated (if applicable)

🤖 Generated with Claude Code

shenxianpeng and others added 2 commits September 24, 2026 13:00
A `nav` entry that links to a section of a page was reported as "not
found in the documentation files", which fails `strict` builds:

- `page.md#anchor` wasn't recognized as a documentation page and was
  kept as a literal link to the Markdown file, which is broken on the
  built site.
- `page/#anchor`, the page's URL, worked on the built site but was
  still reported as not found.

When the part before `#` is a documentation page, the link now points at
the page's URL plus the anchor (`page/#anchor`, or `page.html#anchor`
without directory URLs). Links whose path is the URL of a documentation
page are logged at DEBUG level instead of being reported as not found.

Co-Authored-By: Claude <noreply@anthropic.com>
@github-actions github-actions Bot added the bug Something isn't working label Sep 24, 2026
@codspeed

codspeed Bot commented Sep 24, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 28 untouched benchmarks


Comparing fix/nav-anchor-links (c4583a2) with main (6657fa0)

Open in CodSpeed

@shenxianpeng
shenxianpeng merged commit f85c5e4 into main Sep 24, 2026
23 checks passed
@shenxianpeng
shenxianpeng deleted the fix/nav-anchor-links branch September 24, 2026 10:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant