You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Date in title regression when moving from v16 to v17 (readthedocs) #1382
I updated mkdocs from 0.16.0 to 0.17.2 and noticed the titles of my documents have changed.
I have a folder in the root of my site called meetings with several files that start with a date such as 2017-08-25-adfs-example.md. Some of them are just a date such as 2017-09-12.md.
Before (v16)
In version 16, the hyphens were stripped and this was fine.
After (v17)
In version 17, the titles randomly change depending on which one I click. Sometimes it has a date in it, sometimes it doesnt.
Yes, in #1180 the way page titles are determined was refactored (see nav.pyL213). As explained in the docstring:
Get the title for a Markdown document
Check these in order and return the first that has a valid title:
- self._title which is populated from the mkdocs.yml
- self.meta['title'] which comes from the page metadata
- self.markdown - look for the first H1
- self.input_path - create a title based on the filename
If you were relying on the filename for page titles, that is the last possible method for determining a title. Presumably, one of the other methods are returning a title for some of your pages (my best guess is that some of your pages start with an h1 header). If you manually define a title for those pages using a method with higher priority, then you will be guaranteed to always have the title you want.
Regarding the "regression" claim... The new feature (allow alternate ways to define page titles) has been a long-standing feature request (see #316). And using filenames has always been a fallback. Not defining titles and relying on the fallback is always going to be the most likely to run into unexpected changes. I'm inclined to not consider this a regression.
I understand now. Some of the documents didn't have an <h1> so they still show the date.
However there appears to be a bug that is modifying the title in the menu bar depending on which document I click. It seems like when I click one file, the remaining files listed below go back to displaying the file name (as a date) instead of the <h1>.
It's hard to explain so maybe I can try to reproduce with a new repository.
It sounds like you are experiencing the issue described in #1347. It appears that at that time I did not remember that the changes in #1180 had been applied.
Activity
waylan commentedon Jan 17, 2018
Yes, in #1180 the way page titles are determined was refactored (see nav.pyL213). As explained in the docstring:
If you were relying on the filename for page titles, that is the last possible method for determining a title. Presumably, one of the other methods are returning a title for some of your pages (my best guess is that some of your pages start with an
h1header). If you manually define a title for those pages using a method with higher priority, then you will be guaranteed to always have the title you want.Regarding the "regression" claim... The new feature (allow alternate ways to define page titles) has been a long-standing feature request (see #316). And using filenames has always been a fallback. Not defining titles and relying on the fallback is always going to be the most likely to run into unexpected changes. I'm inclined to not consider this a regression.
styfle commentedon Jan 17, 2018
I understand now. Some of the documents didn't have an
<h1>so they still show the date.However there appears to be a bug that is modifying the title in the menu bar depending on which document I click. It seems like when I click one file, the remaining files listed below go back to displaying the file name (as a date) instead of the
<h1>.It's hard to explain so maybe I can try to reproduce with a new repository.
waylan commentedon Jan 17, 2018
It sounds like you are experiencing the issue described in #1347. It appears that at that time I did not remember that the changes in #1180 had been applied.
waylan commentedon Jun 8, 2018
Closing this as a duplicate of #1447.