What is missing to apply baseof.html to the home page?

I am learning Hugo, starting with a single page site without a theme. After reading Homepage Template and Hugo’s Lookup Order, I started with a single layouts/index.html with a single line as a content

This is the home page

It was a huge success - I saw that line as the output.

Going further, I wanted to add a basic HTML skeleton following the examples in the docs.

I created layouts/_default/baseof.html

<!DOCTYPE html>
<html>
{{- partial "head.html" . -}}

<body>
    {{- partial "header.html" . -}}
    from baseof.html
    <div id="content">
        {{- block "main" . }}{{- end }}
    </div>
    {{- partial "footer.html" . -}}
</body>

</html>

I expect it to always output from baseof.html and the main section of a page. I therefore modified layouts/index.html to

{{ define "main" }}

<main>This is the home page, but better</main>

{{ end }}

I restarted hugo to be sure to start from scratch

PS D:\Nextcloud\dev-perso\blog> hugo server --disableFastRender
Start building sites …
hugo v0.98.0-165d299cde259c8b801abadc6d3405a229e449f6 windows/amd64 BuildDate=2022-04-28T10:23:30Z VendorInfo=gohugoio
WARN 2022/05/01 23:07:11 found no layout file for "HTML" for kind "taxonomy": You should create a template file which matches Hugo Layouts Lookup Rules for this combination.
WARN 2022/05/01 23:07:11 found no layout file for "HTML" for kind "taxonomy": You should create a template file which matches Hugo Layouts Lookup Rules for this combination.

                   | EN
-------------------+-----
  Pages            |  3
  Paginator pages  |  0
  Non-page files   |  0
  Static files     |  0
  Processed images |  0
  Aliases          |  0
  Sitemaps         |  1
  Cleaned          |  0

Built in 10 ms
Watching for changes in D:\Nextcloud\dev-perso\blog\{archetypes,content,data,layouts,static}
Watching for config changes in D:\Nextcloud\dev-perso\blog\config.toml
Environment: "development"
Serving pages from memory
Web Server is available at http://localhost:1313/ (bind address 127.0.0.1)
Press Ctrl+C to stop

and now I get a blank page :frowning:

It looks like layouts/_default/baseof.html is not applied at all (not even the straight from baseof.html string, not to mention any content).

What did I do wrong?

Right after posting, I realized that head.html etc. were not there and this was silently crashing hugo.

I removed everything except the inclusion of main and I got what was expected.

The lack of a warning is I think a problem (especially for newcomers or false beginners)

i’m wondering why you have the width and height value so large in the img tag, even so much larger than largest source webp option. What’s going on there and what’s the appropriate way to do that… I’ve been looking into the picture tag and was wondering what you put in the width and height of the image tag since that’s what “reserves” the space on render so you don’t have content jumping around.

Hmm, are you sure you replied to the right thread? :slight_smile:

You can do hugo new theme theme-name then copy all the files inside theme/theme-name to the base layout folder and then delete the theme. Those files give you an example to start working with. I also created my own site from scratch by using the base layout and then moving all files to a theme.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.