How to make auto-generated (filename-based) document titles have permalink? #6851
-
For our page titles, we mostly rely on the filename; however, we of course sometimes want to override that (especially if it's necessary to have hyphens in the title) by making the first line be the desired title, e.g.: # Explicit title here to override title generated from filename
Content blahblah When we do that, the title ends up with a permalink, which is good. How can we make it so the title ALWAYS has a permalink? (Even when it was just generated from the filename.) The reason I want to do this: I think that permalink next to the title would be the perfect thing to hijack in order to generate a cleaner URL for sharing -- e.g., since I'm using a private repo in GitLab, I want to convert something like
to the shorter and more canonical
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Hello @ryran, mkdocs-material/src/templates/partials/content.html Lines 31 to 40 in 5108432 So there is no permalink added here, probably to avoid any id conflict with another permalink inside the content. You can override the Also for consistency, as mentioned in another discussion:
You can add the hyperlink also using JavaScript, similar to adding a button mentioned in: |
Beta Was this translation helpful? Give feedback.
Hello @ryran,
the permalinks for the headings in the content are generated in the
toc
markdown extension, if you don't have the# title
in the file, the theme extracts the auto-generated title from the filename and adds a<h1>
tag to the page:mkdocs-material/src/templates/partials/content.html
Lines 31 to 40 in 5108432
So there is n…