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?

Thanks

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.

_default/baseof.html

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

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: