31

I recently imported content from my WordPress page into Hugo. When I run hugo serve I get following error messages:

WARN 2020/02/17 20:51:06 found no layout file for "HTML" for "page": You should create a template file which matches Hugo Layouts Lookup Rules for this combination.

The page in question starts like this:

---
linktitle: "The Title of the Post"
title: "The Title of the Post"
author: "Franz Drollig"
type: post
date: 2020-01-09T14:41:55+00:00
url: /the-title-of-post/
categories:
  - Uncategorized
weight: 10

---


This is the content of the post. This is the second sentence of the post. 

It is located in mysite/content/posts/YYYY-MM-DD-title.md.

The layouts directory is empty. However, the themes directory contains the book theme. This theme is also configured in the config.toml.

Another post, starting like shown below, is rendered correctly.

---
author: "Michael Henderson"
date: 2014-09-28
linktitle: Creating a New Theme
menu:
  main:
    parent: tutorials
next: /tutorials/github-pages-blog
prev: /tutorials/automated-deployments
title: Creating a New Theme
weight: 10
---


## Introduction

Why is my post not rendered properly? How can I fix it?

Paulo Boaventura
  • 1,365
  • 1
  • 9
  • 29
  • 2
    I don't have experience with Hugo, but figure I'd comment if it helps to point you in the right direction. The front matter seems very different between those two documents. I'm thinking the the `type: post` is probably the culprit. Does it need quotes around `'post'`? What happens if you remove the `post` front matter altogether? These links may also be helfpul: https://gohugo.io/content-management/front-matter/ and https://gohugo.io/templates/lookup-order/ – epsilon42 Feb 20 '20 at 09:04
  • 2
    @epsilon42 You were right, removing `type: post` solved my problem. If you submit your comment as an answer, I will accept it and you will get the bounty (usually after 2-3 days). –  Feb 20 '20 at 12:55

5 Answers5

88

Okay so here is what is likely happening:

You have a theme you added as a git submodule and you recently re-cloned your project. Guess what? Your submodule needs to be re-downloaded as well.

You can do this with:

git submodule init
git submodule update

Then your project will load without errors.

double-beep
  • 5,031
  • 17
  • 33
  • 41
Mark Wagner
  • 1,011
  • 6
  • 11
9

I don't have experience with Hugo, but figure I'd comment if it helps to point you in the right direction.

The front matter seems very different between those two documents. I'm thinking the type: post is probably the culprit.

What happens if you remove the post front matter altogether?

These links may also be helfpul:
Front Matter | Hugo
Hugo's Lookup Order | Hugo

Shayan Shafiq
  • 1,447
  • 5
  • 18
  • 25
epsilon42
  • 1,863
  • 13
  • 26
  • Note that if you are getting this as part of release pipeline/workflow (such as a GitHub Action), you need to make sure that the checkout step also checks out the submodules which can be off by default (this is the case in the GitHub checkout action). – Oliver Jul 07 '23 at 16:13
8

You have to create the layouts needed; by default the layout of page is named single.html, and the layout of section is named list.html.

Even if you would not use those as a real template, you have to create it in order to avoid that WARN.

So, create those files inside layout/_default: single.html list.html. Also, if you feel applied write some comment with a hugo template inside each file like this:

{{ "<!-- Layout with no content to avoid WARN message about missing page layout -->" | safeHTML }}

5

If you use hugo academic theme, please try this:

$ hugo mod clean
$ hugo server

or

$ hugo mod clean
$ hugo mod get -u ./...
$ hugo server

Ref: Error: File “not found” or “failed to extract” | Troubleshooting

Shayan Shafiq
  • 1,447
  • 5
  • 18
  • 25
user15119773
  • 51
  • 1
  • 1
  • 2
    this is exactly what I needed for this theme since it uses was requiring it in a go.mod and didn't use a submodule. thank you for posting – billspat Feb 03 '21 at 15:49
  • This fixed it for me as well, although I'm using a different theme as a Hugo module. Running `hugo mod get -u` and nothing else fixed it. – leifericf Feb 08 '22 at 08:18
1

In my case, I missed this step:

echo theme = \"hugo-future-imperfect-slim\" >> config.toml

Which adds your theme to the configuration. After that, it was using the right Kinds / Layout elements from the theme. More info in the quick start: https://gohugo.io/getting-started/quick-start/

Boyardee
  • 304
  • 1
  • 6