Use files title instead of front matter title?

Rather than defining the title through the front matter of each of my files, I would prefer if it just used the title of what the actual file is named.
For example, I have a file called ‘Post’, and it would be nice if it would just appear as ‘Post 1’ in my lists, and not have to require me to add the following front matter on that ‘Post’ file:

title: "Post 1"

I saw there was some talk about this back in 2017 but I haven’t seen any follow up. Would it be possible to not need to use front matter for my titles?
(repo if necessary: GitHub - jpnfighter/steve-site: hugo website)

Although I don’t think this a very good idea, you could use a partial.


{{ return or .LinkTitle (.File.TranslationBaseName | humanize) }}

Then replace all instances of {{ .Title }} and {{ LinkTitle }} with {{ partial "title.html" . }}.

You will not be able to use the .ByTitle sorting method, or use .Title in where statements, etc.


1 Like