Is it necessary to have separate templates for homepage and other on a simple site?

Making a simple site with 4-5 pages, every pages use the same layout including the homepage.

I have put a single template file at layouts/_default/single.html but Hugo did not pick this file to show on homepage

Do I need a duplicate template file at layouts/index.html?


I’m new to Hugo, but I think you do need separate templates for index and the others. You can, however, make them the same, using blocks in your base file. Here’s a stripped-down example.


<!DOCTYPE html>
    {{ block "main" . }}{{ end }}

Then, in both index.html and single.html you could have the following, and of course, include whatever structure you want. If you don’t want to duplicate the structure you could put it in a partial and include it in both templates.

{{ define "main" }}
  {{ .Content }}
{{ end }}

They recently changed how the index page works. I just did a quick test, and they can share the same layout page if you place the index file in the contents folder.

What in particular are you trying to accomplish? Can you post your git repo?

Put index file in the contents folder is work :grin:. Now, I just use one template file from layouts/_default/single.html.

Thanks for your help.:heart_eyes: