Open idealhack opened 7 years ago
I got a patch that makes this happen, but dependent on the changes in https://github.com/gohugoio/hugo/pull/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.
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,
No, that is too hacky and not worth it.
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 https://github.com/gohugoio/hugo/pull/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.
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 )
No, that is too hacky and not worth it.
What's hacky about it @bep? Seems like a beautiful way to get rid of an unnecessary required front matter variable. I would love to get rid of all the required front matter entirely to keep the content documents as clean and as portable as possible.
Since now we have support extract the date
from filename by #4494, would it be easier to do this for the title
? I would like to do a PR if there is any guidance.
BTW, I like some ideas in #4341.
This issue has been automatically marked as stale because it has not had recent activity. The resources of the Hugo team are limited, and so we are asking for your help.
If this is a bug and you can still reproduce this error on the master
branch, please reply with all of the information you have about it in order to keep the issue open.
If this is a feature request, and you feel that it is still relevant and valuable, please tell us why.
This issue will automatically be closed in the near future if no further activity occurs. Thank you for all your contributions.
bump
How can I achieve this functionality?
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?