Skip to content

Fix five small page bugs: raw HTML links, home page, title, metadata - #170

Merged
shenxianpeng merged 2 commits into
mainfrom
claude/project-thread-ckcodu
Nov 7, 2026
Merged

shenxianpeng merged 2 commits into
mainfrom
claude/project-thread-ckcodu

Conversation

@shenxianpeng

@shenxianpeng shenxianpeng commented Nov 7, 2026 •

Copy link
Copy Markdown
Member

Five small bugs that MkDocs NG 1.11.1 still has. Each one breaks a page in a way users notice, and none of the fixes changes a page that builds correctly today.

  • Relative URLs in raw HTML. An img tag with src="img/a.png" inside a figure in sec/page.md broke with use_directory_urls, because only Markdown links were adjusted. Relative src and href URLs in raw HTML are now adjusted the same way, but only when they point to a file in docs_dir relative to the Markdown file and don't already work from the built page. So HTML that was hand-written for the built site (../../img/a.png) stays as it is. Only standard elements (a, img, video, source, iframe and a few more) are adjusted: custom elements such as swagger-ui belong to a plugin that resolves the URL itself (the compatibility check caught this for mkdocs-swagger-ui-tag). Code blocks and inline code are not touched. Lookups go through get_file_from_path, so the mkdocs serve render cache sees them.
  • page.is_homepage in a section. It was False for the root index.md when nav put it inside a section, so themes didn't treat it as the home page.
  • HTML comment before the first heading. A license header such as an SPDX comment stopped the # Heading below it from becoming the page title. Only comments are skipped; other HTML before the heading still means there is no title from the content.
  • Foo: Bar underlined with ===. It was read as MultiMarkdown metadata, so the heading disappeared. Only === counts as a heading underline here; Title: X followed by --- keeps working as metadata plus a rule.
  • Front matter without a final newline. Front matter whose closing --- is the last line of the file, with no newline after it, was ignored.

Checked: the MkDocs NG docs site and the Sumi docs site (both languages) build byte-for-byte the same before and after, except for the pages this PR edits.

Related Issue

Roadmap item 48 in #59.

Checklist

  • New tests added for new behavior (if applicable)
  • Documentation updated (if applicable): "Linking from raw HTML" in Writing your docs, Fixed Upstream Issues page
  • Release notes docs/about/release-notes.md updated (if applicable): under 1.11.2 (unreleased)

- Relative `src` and `href` URLs in raw HTML are adjusted like Markdown
  links when they point to a file in docs_dir relative to the Markdown
  file, so an `<img>` in a `<figure>` works with use_directory_urls.
  A URL that already works from the built page is left as it is.
- `page.is_homepage` is True for the root index.md also when `nav`
  puts it inside a section.
- HTML comments above the first heading (license headers) no longer
  stop the heading from becoming the page title.
- `Foo: Bar` underlined with `===` is a heading, not MultiMarkdown
  metadata. `---` below metadata keeps working as before.
- YAML front matter is read when the file ends right after the
  closing `---`.
@github-actions github-actions Bot added the bug Something isn't working label Nov 7, 2026
@shenxianpeng shenxianpeng self-assigned this Nov 7, 2026
Custom elements such as <swagger-ui src="openapi.json"/> belong to a
plugin that resolves the URL itself, so adjusting it broke
mkdocs-swagger-ui-tag in the plugin compatibility check.
@codspeed

codspeed Bot commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 29 untouched benchmarks


Comparing claude/project-thread-ckcodu (ee7ee77) with main (9c1b76f)

Open in CodSpeed

@shenxianpeng
shenxianpeng merged commit f421e49 into main Nov 7, 2026
26 checks passed
@shenxianpeng
shenxianpeng deleted the claude/project-thread-ckcodu branch November 7, 2026 14:00

This branch was successfully deployed

1 active deployment
preview — ee7ee77d Deployed Nov 7, 2026 by shenxianpeng via preview #542
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