-
-
Notifications
You must be signed in to change notification settings - Fork 7.6k
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
Use filename as title when it’s not defined in front matter #3805
Comments
I got a patch that makes this happen, but dependent on the changes in #3762 that in addition to deriving date from filename also fixes how metadata defaults are calculated which is needed to fix title handling. If that PR gets merged in I can easily make a PR for this issue too. |
note I think its worth going a level further and try detect if content has a top level header as defined by markdown, asciidoc or orgmode and use that header if present, if not use filename. |
No, that is too hacky and not worth it. |
too hacky? as compared to try derive from filename ? It works pretty well in awestruct and others and it has the big plus your blog posts actually render with proper title when shown "raw" in github. |
btw. made the patch before I saw your comment so you can see the idea at #3859 |
note, the idea is similar to extract toc and summary that tries to parse raw and generated content to derive "metadata". |
Note that the current TOC solution is also considered "hacky and slow" in my book, and will be fixed once Blackfriday 2 is out. We're not doing any regexp magic looking for titles. Also, I'm not a big fan of pull requests that try to do more than the issue they describe. Do one thing well. |
okey - I've updated patch to just to title based on filename/slug. I hope this can merged in together with the date fallback which this fix is dependent on (as without it metadata fallback calculation sequences are different whether there is a frontmatter or not ) |
Note: I'm new to Hugo, so If there's a better way about this fell free to correct me.
For now I use
{{.File.TranslationBaseName}}
in template cause{{.Title}}
is empty string. I thought it's better to store it in the title variable, as themes out there are already using it. Also we could use file dates fordate
andlastmod
.I thought this is a nice feature especially when there're a lot of content files imported from another system.
For myself, I use nvALT to take markdown notes. nvALT has already handle the title and date in this way, now I want to use Hugo for building the website. But maintaining notes metadata by hand is not a good practice IMHO.
What do you think?
The text was updated successfully, but these errors were encountered: