In a lot of Hugo projects I end up with a decent amount of markdown files in
content that are basically empty. But they are needed because Hugo does only generate a page if I have a content file. It looks like this:
└── content └── about | └── _index.md // <- example.com/about/ └── posts ├── happy | └── index.md // <- example.com/posts/happy/ └── _index.md // <- example.com/posts/ └── layouts ├── _default │ └── baseof.html ├── about │ ├── index.html // <- DOES NOT WORK, BUT MAYBE IT SHOULD? │ └── list.html // <- example.com/about/ ├── posts │ ├── list.html │ └── single.html └── index.html // <- example.com/
In the above example, I would just like to have a file in
layouts/about/index.html that is constructed together with
baseof.html and maybe some partials that are included. For a page that is very unique - like about pages usually are - I can just write everything in HTML and don’t see the point in creating an additional file
Everything should work like the Homepage Template
Wouldn’t it make sense for Hugo to also take template files under
layouts that are not
single.html and render them? This would be the exact same behavior as the homepage template’s
Better Learning Path
Besides avoiding some unnecessary markdown files in the content folder, there is another reason why I’m asking for this feature: it would enable a very easy learning path for developers as they adopt Hugo for their first SSG project.
Let me explain: I teach a lot of web development to people that are new to programming. Our learning path usually goes like this (also see my HTML/CSS tutorials for details):
- Learn very basic HTML
- Learn very basic CSS
- Upload to a simple static hosting like Netlify
Students can get very far with this. But after a while they will end up with a lot of HTML-pages. And every page, of course, contains a copy of things like
<head> and navigation. Students then ask, if there is a better way. And my answer usually is Hugo.
But this step is bigger than it needs to be. If Hugo would allow the above mentioned way to generate layout pages without the need for content files, it would make things much easier.
I could just tell the students: Now, copy everything to the
layouts folder. Then use
baseof.html for the code that is duplicated across multiple. And everything would work and make sense to the students.
Only as a later step I would introduce them to the concept of the
content folder and Markdown - probably to show the benefit when having a collection of “things” like blog posts.
What are your thoughts? Do you see a better way to do this or is this a valid feature request for Hugo?