Original post was at https://github.com/spf13/hugo/issues/1212 but I was redirected here.
I find that Hugo is severely lacking and the current project architecture is just not that good for DRY. Let me explain:
All HTML pages are currently rendered based on content
files. e.g content/features.html
~> example.com/features/
will exist. However, content does not support any logic and actually not even HTML officially (docs say that files in content
should be in Markdown).
The docs also say that “most sites will only need a home page and the _default template”. I don’t find this to be true at all. In fact, I end up doing templates for almost EVERY page on my site and a corresponding content for that. This is because I want to create my pages’ contents from small partials too and not just have header, nav and footer come from the template.
Concrete example:
content/
features.html
pricing.html
about.html
layouts/
_default/
single.html
partials/
...lots of partials here...
index.html
-
example.com/
is now easy to build by using logic and partials because index.html is a template and all the Go magic is at my disposal. -
example.com/about/
is also easy because it just has some text that is added to the_default/single.html
template from about.html. -
example.com/features/
andexample.com/pricing/
are a bit more complex pages and would otherwise fit inside the_default/single.html
but I want to use Go logic to render things. Problem:content
doesn’t support Go logic.
To overcome the problem with features
and pricing
I can change my structure to this:
content/
features.html
pricing.html
about.html
layouts/
_default/
single.html
features/
single.html
pricing/
single.html
partials/
...lots of partials here, used in index, about and pricing...
index.html
However, the above is just stupid. Why would I want so many folders and files, especially when all my logic files have the same name: single.html ?
Another concrete example:
I have a _default/single.html that can support my blog posts. Excellent! However, my blog post structure is like this:
<lorem ipsum text here...>
<banner with something, easy to include as a partial>
<lorem ipsum text continues here...>
The problem is that, again, I couldn’t do a blogpost.md
that looks like:
lorem ipsum text here..
{{ partial "adbanner.html" . }}
lorem ipsum text here..
and I can’t do a template that looks like:
{{ .FirstHalfContent }}
{{ partial "adbanner.html" . }}
{{ .SecondHalfContent }}
So basically I would have to write the first half of the blog post to blogpost.md
, the second half to blogpostsecondhalf.html
to a partial
and then do a template like:
{{ .Content }}
{{ partial "adbanner.html" . }}
{{ partial .Params.SecondHalfContent . }} <!-- the correct partial declared in FrontMatter -->
Umm… yeahh… I would much rather just import to partial within the file containing the blogpost.
Right now I notice that I end up doing a lot of content
files that ONLY contain the frontmatter
and a lot of textcontent and even HTML in the variables so I can do more multi-purpose templates and properly use partials.
Ideally, I’d probably enjoy a project where I could do easily use Go logic in all the files that get rendered into HTML pages. For example, inside the whatever-gets-injected-into {{ .Content }} in the following:
{{ partial "header.html" . }}
{{ partial "nav.html" . }}
{{ .Content }}
{{ partial "footer.html" . }}
Is it so that Hugo is only for blogs where almost every page looks the same? Should I be using Jekyll or something else instead ? Or am I missing something relevant here ?