I have a use case where a title is not required for a certain post type. Is there a way to disable it’s addition when using hugo new
?
Hugo sets the title automatically based on the filename and I’m not aware of a config option to disable this behavior. However, you could use an archetype for the post type that contains title = ""
.
Either Hugo processes the archetype first and overwrites it automatically. Or this happens vice versa and you end up with an empty string as title.
My current archetype looks like:
---
title:
---
which produces a page:
---
date: 2017-01-xxxx...
title: null
---
Which, while adding an extraneous line seems to exhibit the correct behaviour. I was just hoping they’d be a better way.
Try with an empty string, i.e: title: ""
Same behaviour now with an empty string instead of a null value.
This was actually the intention of my workaround. The title will be set regardless what you do. I can understand that this workaround isn’t perfect. But when dealing with the title in the templates it should behave nearly the same way as if the title isn’t set at all.
Ah, thanks for the clarification. Didn’t fully get my head round your explanation first time around. Thanks for the help!