Skip to content

📝 Add permalinks to headers in English docs#13993

Merged
tiangolo merged 13 commits intomasterfrom
add-permalinks-to-en-docs
Aug 31, 2025
Merged

📝 Add permalinks to headers in English docs#13993
tiangolo merged 13 commits intomasterfrom
add-permalinks-to-en-docs

Conversation

@YuriiMotov
Copy link
Member

@YuriiMotov YuriiMotov commented Aug 15, 2025

This PR adds permalinks to all headers of English pages in docs.
Permalinks were added using script.

The following edge cases are handled by script:

  • exclude non-translated sections
  • handle comments inside code blocks
  • only add permalink if not exist (ensure second run will not add second permalink)
  • handle html-tags in headers (use only visible text to generate permalink)

This PR also:

  • bumps mkdocs-macros-plugin to 1.3.9 (commit) - should I open a separate PR for this commit?
  • patches mkdocs_hooks.py to avoid conflict with attr_lists extension (commit)

@YuriiMotov YuriiMotov added the docs Documentation about how to use FastAPI label Aug 15, 2025
@github-actions

This comment was marked as outdated.

@github-actions

This comment was marked as outdated.

@github-actions

This comment was marked as outdated.

@YuriiMotov YuriiMotov marked this pull request as ready for review August 17, 2025 06:41
Copy link
Contributor

@nilslindemann nilslindemann left a comment

Choose a reason for hiding this comment

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

This is good. 👍

I have gone through the files manually. A project wide search in VS Code ...

  • Regex: ^(#+)[^\S\n]*(.+?)[^}\s][^\S\n]*$ (headings which do not end with })
  • Include: docs/en/docs/**/*.md
  • Exclude: reference/**/, release-notes.md, fastapi-people.md, external-links.md, newsletter.md, management-tasks.md, management.md, contributing.md

... finds only comments in code blocks, so indeed all headings in the English docs have permalinks now.

Great work Yurii, including all the edge cases you detected. Also thanks for the examples.

Copy link
Member

@svlandeg svlandeg left a comment

Choose a reason for hiding this comment

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

Nice work!

Left a few small comments. Except for the first one, most of them are small nitpicks/personal preferences, which you can feel free to ignore if you don't agree.

In general I'm not sure the very first heading on L1 of each file needs a permalink, but I guess it doesn't hurt either.

Some of them also get quite long, like #include-an-apirouter-with-a-custom-prefix-tags-responses-and-dependencies but I guess it's fine to just stick to the title almost 1-1.

@svlandeg
Copy link
Member

So with respect to my nitpicking comments

Permalinks were added using script.

Is there any way the script can be edited to not convert 's to -s- but instead maybe just paste it to the previous word? Again, also fine if it's not possible.

Also, where is the script?

@github-actions

This comment was marked as outdated.

@github-actions

This comment was marked as outdated.

@YuriiMotov
Copy link
Member Author

I modified the script to do some replacements before generating the slug (commit 1, commit 2):

        replacements=[
            ("`", ""),  # `dict`s -> dicts
            ("'s", "s"),  # it's -> its
            ("'t", "t"),  # don't -> dont
            ("**", ""),  # **FastAPI**s -> FastAPIs
        ],

With these changes we will add s to the end of possessive forms (FastAPI's -> fastapis). That's because it's hard to distinguish this case and the it's\that's cases.

Also, now script appends permalinks with the unique indexes if initial slug is already used on the page (see commit).

@github-actions
Copy link
Contributor

📝 Docs preview for commit 3101da8 at: https://bcc3018e.fastapitiangolo.pages.dev

Modified Pages

Copy link
Member

@svlandeg svlandeg left a comment

Choose a reason for hiding this comment

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

Nice!

I reviewed in detail last week and everything's been addressed, so this looks good to merge 🎉

@nilslindemann
Copy link
Contributor

Yeah, LGTM, it will make my Gargantua PR easier to review :-D

Copy link
Member

@tiangolo tiangolo left a comment

Choose a reason for hiding this comment

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

Nice, awesome, thank you @YuriiMotov! 🙌

And thanks for the reviews @svlandeg and @nilslindemann ! ☕

@tiangolo tiangolo enabled auto-merge (squash) August 31, 2025 09:13
@tiangolo tiangolo merged commit c55f713 into master Aug 31, 2025
51 checks passed
@tiangolo tiangolo deleted the add-permalinks-to-en-docs branch August 31, 2025 09:15
nilslindemann added a commit to nilslindemann/fastapi that referenced this pull request Sep 1, 2025
commit 176cd8c
Author: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Date:   Sun Aug 31 15:20:12 2025 +0000

    📝 Update release notes

    [skip ci]

commit 1884d76
Author: Sebastián Ramírez <[email protected]>
Date:   Sun Aug 31 17:19:49 2025 +0200

    🔧 Update sponsors: remove Platform.sh (fastapi#14027)

commit 8062aab
Author: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Date:   Sun Aug 31 15:02:29 2025 +0000

    📝 Update release notes

    [skip ci]

commit ee9ccac
Author: Sebastián Ramírez <[email protected]>
Date:   Sun Aug 31 17:02:08 2025 +0200

    🔧 Update sponsors: remove Mobb (fastapi#14026)

commit 5cd4c3b
Author: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Date:   Sun Aug 31 10:59:17 2025 +0000

    📝 Update release notes

    [skip ci]

commit 4584f70
Author: Jom Karlo Verzosa <[email protected]>
Date:   Sun Aug 31 18:58:56 2025 +0800

    📝 Add deprecation info block about `dict()` in `docs/tutorial/body.md` (fastapi#13906)

    Co-authored-by: Sebastián Ramírez <[email protected]>

commit ba9c8fb
Author: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Date:   Sun Aug 31 10:50:12 2025 +0000

    📝 Update release notes

    [skip ci]

commit d9249c1
Author: Valentyn <[email protected]>
Date:   Sun Aug 31 06:49:48 2025 -0400

    📝 Fix Twitter to be X (Twitter) everywhere in documentation (fastapi#13809)

    Co-authored-by: Valentyn Druzhynin <[email protected]>
    Co-authored-by: Sebastián Ramírez <[email protected]>

commit a973e78
Author: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Date:   Sun Aug 31 10:33:32 2025 +0000

    📝 Update release notes

    [skip ci]

commit 1088d2a
Author: Ashish Pandey <[email protected]>
Date:   Sun Aug 31 16:17:57 2025 +0545

    🐛 Prevent scroll-to-top on restart/fast buttons in `termynal.js` (fastapi#13714)

    Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>

commit 98ec6a6
Author: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Date:   Sun Aug 31 10:29:48 2025 +0000

    📝 Update release notes

    [skip ci]

commit 6b4d292
Author: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Date:   Sun Aug 31 10:29:27 2025 +0000

    📝 Update release notes

    [skip ci]

commit d4ddcc5
Author: z0z0r4 <[email protected]>
Date:   Sun Aug 31 18:29:21 2025 +0800

    📝 Update testing events documentation (fastapi#13259)

    Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
    Co-authored-by: Motov Yurii <[email protected]>
    Co-authored-by: Sebastián Ramírez <[email protected]>

commit 0e5832a
Author: Hotah Ma <[email protected]>
Date:   Sun Aug 31 18:29:01 2025 +0800

    📝 Remove obsolete `url` field in error responses in docs (fastapi#13655)

    Co-authored-by: Motov Yurii <[email protected]>

commit ee2acd8
Author: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Date:   Sun Aug 31 10:03:35 2025 +0000

    📝 Update release notes

    [skip ci]

commit e902ed5
Author: Arnaud Durand <[email protected]>
Date:   Sun Aug 31 12:03:10 2025 +0200

    📝 Bring the `scope` claim in line with the standard in `docs_src/security/tutorial005.py` (fastapi#11189)

    Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
    Co-authored-by: Yurii Motov <[email protected]>

commit cef1f16
Author: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Date:   Sun Aug 31 09:59:28 2025 +0000

    📝 Update release notes

    [skip ci]

commit 8e63f75
Author: Soul Lee <[email protected]>
Date:   Sun Aug 31 18:59:07 2025 +0900

    📝 Update TrustedHostMiddleware Documentation (fastapi#11441)

    Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
    Co-authored-by: Alejandra <[email protected]>
    Co-authored-by: Sofie Van Landeghem <[email protected]>
    Co-authored-by: Sebastián Ramírez <[email protected]>
    Co-authored-by: Motov Yurii <[email protected]>

commit e1b9cc0
Author: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Date:   Sun Aug 31 09:56:48 2025 +0000

    📝 Update release notes

    [skip ci]

commit 408b8a9
Author: Denny Biasiolli <[email protected]>
Date:   Sun Aug 31 11:56:21 2025 +0200

    📝 Remove links to site callbackhell.com that doesn't exist anymore (fastapi#14006)

commit 0817c95
Author: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Date:   Sun Aug 31 09:16:03 2025 +0000

    📝 Update release notes

    [skip ci]

commit c55f713
Author: Motov Yurii <[email protected]>
Date:   Sun Aug 31 11:15:41 2025 +0200

    📝 Add permalinks to headers in English docs (fastapi#13993)

    Co-authored-by: Sebastián Ramírez <[email protected]>

commit 7653de2
Author: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Date:   Sun Aug 31 09:11:36 2025 +0000

    📝 Update release notes

    [skip ci]

commit 784f068
Author: Sebastián Ramírez <[email protected]>
Date:   Sun Aug 31 11:11:15 2025 +0200

    🛠️ Update `mkdocs_hooks` to handle headers with permalinks when building docs (fastapi#14025)

    Co-authored-by: Yurii Motov <[email protected]>

commit 6db0577
Author: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Date:   Mon Aug 25 20:03:24 2025 +0000

    📝 Update release notes

    [skip ci]

commit 6be02e3
Author: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Date:   Mon Aug 25 22:03:02 2025 +0200

    ⬆ [pre-commit.ci] pre-commit autoupdate (fastapi#14016)

    updates:
    - [github.com/astral-sh/ruff-pre-commit: v0.12.9 → v0.12.10](astral-sh/ruff-pre-commit@v0.12.9...v0.12.10)

    Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>

commit 9cf7b70
Author: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Date:   Wed Aug 20 09:11:20 2025 +0000

    📝 Update release notes

    [skip ci]

commit f75c153
Author: Motov Yurii <[email protected]>
Date:   Wed Aug 20 11:10:51 2025 +0200

    ⬆ Bump `mkdocs-macros-plugin` from 1.3.7 to 1.3.9 (fastapi#14003)

    Bump mkdocs-macros-plugin from 1.3.7 to 1.3.9

commit 5c3a70d
Author: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Date:   Mon Aug 18 21:07:25 2025 +0000

    📝 Update release notes

    [skip ci]

commit 6a45249
Author: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Date:   Mon Aug 18 23:07:04 2025 +0200

    ⬆ [pre-commit.ci] pre-commit autoupdate (fastapi#13999)

    updates:
    - [github.com/astral-sh/ruff-pre-commit: v0.12.8 → v0.12.9](astral-sh/ruff-pre-commit@v0.12.8...v0.12.9)

    Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>

commit c230516
Author: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Date:   Mon Aug 18 06:35:06 2025 +0000

    📝 Update release notes

    [skip ci]

commit df77988
Author: Mika <[email protected]>
Date:   Mon Aug 18 14:34:40 2025 +0800

    📝 Fix code include for Pydantic models example in `docs/zh/docs/python-types.md` (fastapi#13997)

    Updated the Pydantic expiration example in the Chinese documentation
nilslindemann added a commit to nilslindemann/fastapi that referenced this pull request Sep 1, 2025
commit 3e2dbf9
Author: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Date:   Sun Aug 31 19:34:37 2025 +0000

    📝 Update release notes

    [skip ci]

commit f5b77ff
Author: Sebastián Ramírez <[email protected]>
Date:   Sun Aug 31 21:34:08 2025 +0200

    📝 Add documentation for Behind a Proxy - Proxy Forwarded Headers, using `--forwarded-allow-ips="*"` (fastapi#14028)

    Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>

commit 176cd8c
Author: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Date:   Sun Aug 31 15:20:12 2025 +0000

    📝 Update release notes

    [skip ci]

commit 1884d76
Author: Sebastián Ramírez <[email protected]>
Date:   Sun Aug 31 17:19:49 2025 +0200

    🔧 Update sponsors: remove Platform.sh (fastapi#14027)

commit 8062aab
Author: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Date:   Sun Aug 31 15:02:29 2025 +0000

    📝 Update release notes

    [skip ci]

commit ee9ccac
Author: Sebastián Ramírez <[email protected]>
Date:   Sun Aug 31 17:02:08 2025 +0200

    🔧 Update sponsors: remove Mobb (fastapi#14026)

commit 5cd4c3b
Author: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Date:   Sun Aug 31 10:59:17 2025 +0000

    📝 Update release notes

    [skip ci]

commit 4584f70
Author: Jom Karlo Verzosa <[email protected]>
Date:   Sun Aug 31 18:58:56 2025 +0800

    📝 Add deprecation info block about `dict()` in `docs/tutorial/body.md` (fastapi#13906)

    Co-authored-by: Sebastián Ramírez <[email protected]>

commit ba9c8fb
Author: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Date:   Sun Aug 31 10:50:12 2025 +0000

    📝 Update release notes

    [skip ci]

commit d9249c1
Author: Valentyn <[email protected]>
Date:   Sun Aug 31 06:49:48 2025 -0400

    📝 Fix Twitter to be X (Twitter) everywhere in documentation (fastapi#13809)

    Co-authored-by: Valentyn Druzhynin <[email protected]>
    Co-authored-by: Sebastián Ramírez <[email protected]>

commit a973e78
Author: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Date:   Sun Aug 31 10:33:32 2025 +0000

    📝 Update release notes

    [skip ci]

commit 1088d2a
Author: Ashish Pandey <[email protected]>
Date:   Sun Aug 31 16:17:57 2025 +0545

    🐛 Prevent scroll-to-top on restart/fast buttons in `termynal.js` (fastapi#13714)

    Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>

commit 98ec6a6
Author: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Date:   Sun Aug 31 10:29:48 2025 +0000

    📝 Update release notes

    [skip ci]

commit 6b4d292
Author: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Date:   Sun Aug 31 10:29:27 2025 +0000

    📝 Update release notes

    [skip ci]

commit d4ddcc5
Author: z0z0r4 <[email protected]>
Date:   Sun Aug 31 18:29:21 2025 +0800

    📝 Update testing events documentation (fastapi#13259)

    Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
    Co-authored-by: Motov Yurii <[email protected]>
    Co-authored-by: Sebastián Ramírez <[email protected]>

commit 0e5832a
Author: Hotah Ma <[email protected]>
Date:   Sun Aug 31 18:29:01 2025 +0800

    📝 Remove obsolete `url` field in error responses in docs (fastapi#13655)

    Co-authored-by: Motov Yurii <[email protected]>

commit ee2acd8
Author: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Date:   Sun Aug 31 10:03:35 2025 +0000

    📝 Update release notes

    [skip ci]

commit e902ed5
Author: Arnaud Durand <[email protected]>
Date:   Sun Aug 31 12:03:10 2025 +0200

    📝 Bring the `scope` claim in line with the standard in `docs_src/security/tutorial005.py` (fastapi#11189)

    Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
    Co-authored-by: Yurii Motov <[email protected]>

commit cef1f16
Author: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Date:   Sun Aug 31 09:59:28 2025 +0000

    📝 Update release notes

    [skip ci]

commit 8e63f75
Author: Soul Lee <[email protected]>
Date:   Sun Aug 31 18:59:07 2025 +0900

    📝 Update TrustedHostMiddleware Documentation (fastapi#11441)

    Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
    Co-authored-by: Alejandra <[email protected]>
    Co-authored-by: Sofie Van Landeghem <[email protected]>
    Co-authored-by: Sebastián Ramírez <[email protected]>
    Co-authored-by: Motov Yurii <[email protected]>

commit e1b9cc0
Author: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Date:   Sun Aug 31 09:56:48 2025 +0000

    📝 Update release notes

    [skip ci]

commit 408b8a9
Author: Denny Biasiolli <[email protected]>
Date:   Sun Aug 31 11:56:21 2025 +0200

    📝 Remove links to site callbackhell.com that doesn't exist anymore (fastapi#14006)

commit 0817c95
Author: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Date:   Sun Aug 31 09:16:03 2025 +0000

    📝 Update release notes

    [skip ci]

commit c55f713
Author: Motov Yurii <[email protected]>
Date:   Sun Aug 31 11:15:41 2025 +0200

    📝 Add permalinks to headers in English docs (fastapi#13993)

    Co-authored-by: Sebastián Ramírez <[email protected]>

commit 7653de2
Author: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Date:   Sun Aug 31 09:11:36 2025 +0000

    📝 Update release notes

    [skip ci]

commit 784f068
Author: Sebastián Ramírez <[email protected]>
Date:   Sun Aug 31 11:11:15 2025 +0200

    🛠️ Update `mkdocs_hooks` to handle headers with permalinks when building docs (fastapi#14025)

    Co-authored-by: Yurii Motov <[email protected]>

commit 6db0577
Author: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Date:   Mon Aug 25 20:03:24 2025 +0000

    📝 Update release notes

    [skip ci]

commit 6be02e3
Author: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Date:   Mon Aug 25 22:03:02 2025 +0200

    ⬆ [pre-commit.ci] pre-commit autoupdate (fastapi#14016)

    updates:
    - [github.com/astral-sh/ruff-pre-commit: v0.12.9 → v0.12.10](astral-sh/ruff-pre-commit@v0.12.9...v0.12.10)

    Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>

commit 9cf7b70
Author: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Date:   Wed Aug 20 09:11:20 2025 +0000

    📝 Update release notes

    [skip ci]

commit f75c153
Author: Motov Yurii <[email protected]>
Date:   Wed Aug 20 11:10:51 2025 +0200

    ⬆ Bump `mkdocs-macros-plugin` from 1.3.7 to 1.3.9 (fastapi#14003)

    Bump mkdocs-macros-plugin from 1.3.7 to 1.3.9

commit 5c3a70d
Author: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Date:   Mon Aug 18 21:07:25 2025 +0000

    📝 Update release notes

    [skip ci]

commit 6a45249
Author: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Date:   Mon Aug 18 23:07:04 2025 +0200

    ⬆ [pre-commit.ci] pre-commit autoupdate (fastapi#13999)

    updates:
    - [github.com/astral-sh/ruff-pre-commit: v0.12.8 → v0.12.9](astral-sh/ruff-pre-commit@v0.12.8...v0.12.9)

    Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>

commit c230516
Author: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Date:   Mon Aug 18 06:35:06 2025 +0000

    📝 Update release notes

    [skip ci]

commit df77988
Author: Mika <[email protected]>
Date:   Mon Aug 18 14:34:40 2025 +0800

    📝 Fix code include for Pydantic models example in `docs/zh/docs/python-types.md` (fastapi#13997)

    Updated the Pydantic expiration example in the Chinese documentation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Documentation about how to use FastAPI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants