-
Notifications
You must be signed in to change notification settings - Fork 92
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to modify pages titles? #79
Comments
Can you be a bit more specific? In particular, can you posted the relevant parts of your conf and the rst page? |
Hmm, I'm not sure I get what you mean, but here is my a file without header/title. And here are the relevant parts of the import sphinx_material
project = 'Kune'
release = '0.1'
extensions = [
'sphinx.ext.autodoc',
'sphinx.ext.viewcode',
'sphinx_copybutton',
]
html_sidebars = {
"**": ["logo-text.html", "globaltoc.html", "localtoc.html", "searchbox.html"]
}
extensions.append("sphinx_material")
html_theme_path = sphinx_material.html_theme_path()
html_context = sphinx_material.get_html_context()
html_theme = "sphinx_material"
html_theme_options = {
'nav_title': 'Kune servers documentation',
'globaltoc_depth': 3,
'globaltoc_collapse': True,
'globaltoc_includehidden': True,
} Using this configuration, the resulting HTML tag is I would like to know how to make the resulting tag EDIT, also, I guess you already know that, if I set |
This seems to be Sphinx's default for a page with no title. This "title" ( This could be addressed here, but it may not be the right place for a fix. Sphinx might be the right place to have an option to override the default value of Normally the title is read from the pages top heading. |
Does not seem to provide a method to override. |
Thanks, I'll move this to sphinx then and patch it on my side in the mean time. |
Great. I'd rather not try and fitis here since it would be pretty hacky, something along the lines of
which is very dependent on how sphinx renders "no title". I would suggest that Sphinx could add an enhancement for conf.py that would be something like |
That patch is not enough sadly, there is another place that treats title apparently. Here is how I patched it (at least to remove the from docutils import nodes
from sphinx.application import Sphinx
from sphinx.environment.collectors.title import TitleCollector
_process_doc = TitleCollector.process_doc
def process_doc(self, app: Sphinx, doctree: nodes.document) -> None:
if doctree.traverse(nodes.section):
_process_doc(self, app, doctree)
else:
titlenode = nodes.title()
app.env.titles[app.env.docname] = titlenode
app.env.longtitles[app.env.docname] = titlenode
TitleCollectorprocess_doc = process_doc This renders Another problem is that, even with setting a title manually in the toctree: |
The - removal would need to come from sphinx-material. If title is empty, then the page title should be html_title if present, and it not, nothing (which might not be 100% compliant in HTML). |
The title wouldn't be empty, it would be equal to |
That is what I mean. One challenge is that html_title has been escaped before it get to templating and the - has been manually inserted, and so some string parsing is needed. Not the end of the world, but starting to feel fragile. This hardcoded behaviour is a misfeature of Sphinx IMO. |
There is a start in#81. It will need to become opt-in before it can be merged. |
I'm trying to modify a page title without having an
<h1>
tag in my page. Is it possible?The current behaviour when setting
html_title = 'test'
is to output<no title> test
. I would for example like to remove the<no title>
part so my page title is equal tohtml_title
. Do I need to create a template for that?The text was updated successfully, but these errors were encountered: