Templating: Compared to Jekyll, I’m completely lost

Hugo Templating Structure

Hi @onlinemantas - I’ve built a lot of Jekyll and Hugo sites. While Jekyll’s templating is easier to understand, Hugo’s allows for a great deal of complexity should you need it.

While I can only speak about how I’ve used them, here are a couple of thoughts to start you on your way.

Where Jekyll has default.html Hugo has _default/baseof.html where you would put your basic site structure.

There are two other templates that handle a lot of heavy lifting:

  1. _default/list.html This is where you’d put your logic for listing content from a particular section.

  2. _default/single.html This is where you’d put your content for a single page

You can override those for a particular section by adding section templates to your layouts folder.

So, if you have a “section” (“collection,” in Jekyll) called “post” you would create a folder called “post” and within that folder put a template called single.html that will override the default single (_default/single.html).

You can also put various “views” for the post section in that folder, but that’s another topic.

To override the list template for the “post” section, you’d add a template for it in a “section” folder: section/post.html.

As @moorereason said, the home page is merely the index.html template in your layouts folder.

I know coming from Jekyll this may seem a bit overly complicated, but these inheritance rules allow for robust theming and complex sites with some enforced consistency.

Here’s a link a post with links to a theme I built to help someone get started, and maybe playing with that will help (might be easiest to clone the demo repo)

That’s a start. The docs are good, but can still be overwhelming. Take it a little farther and see what questions you come up with

1 Like