Home renders content/_index.md but not content directories locally

Hi, I’m trying to get some very minimal Hugo content displaying in order to learn the tool, but I’m having a bit of trouble getting consistent results between what’s served locally and deployed site.

I’m essentially trying to implement the homepage example from the docs here. https://gohugo.io/templates/homepage/ . Locally when I run hugo serve no content from the content directory post displays locally. Likewise when I run hugo the output in public/ does contain any content from post. However when I deployed my site to Netlify there was content in `post displayed.

├── README.md
├── archetypes
│   └── default.md
├── config.toml
├── content
│   ├── _index.md
│   └── post
│       └── intro.md
├── data
├── layouts
│   ├── index.html
│   └── post
│       └── post.html
├── resources
│   └── _gen
│       ├── assets
│       └── images
├── static
└── themes

All content is marked as draft: false.

There are warnings about taxonomy issues when running both locally and during deployment, but I’m guessing that shouldn’t be causing any issues I’m experiencing.

11:15:17 PM: WARN 2019/11/19 07:15:17 Found no layout for "page", language "en", output format "HTML": create a template below /layouts with one of these filenames: post/single.en.html.html, 
...
11:15:17 PM: WARN 2019/11/19 07:15:17 Found no layout for "taxonomyTerm", language "en", output format "HTML": create a template below /layouts with one of these filenames: 
...
11:15:17 PM: WARN 2019/11/19 07:15:17 Found no layout for "taxonomyTerm", language "en", output format "HTML": create a template below /layouts with one of these filenames: ...

Here’s a repo of the site. Thanks in advance! https://gitlab.com/dylankb/hugo-example

The error states exactly what is wrong:

content/post/intro.md is a regular page; you do not have a layout file for regular pages. Have a read here for Hugo’s layout lookup order: Template lookup order | Hugo

Thanks for the response @pointyfar

Adding layouts/posts/single.html now renders content at /post/intro/ and removes that particular warning, however this wasn’t my goal.

I’m essentially trying to implement the homepage example from the docs here. Homepage template | Hugo

What I was trying to do was get to get all post content to render from / using this type of snippet.

      <div>
        <!-- Note that .Pages is the same as .Site.RegularPages on the homepage template. -->
        {{ range first 10 .Pages }}
            {{ .Render "summary"}}
        {{ end }}
      </div>

So my layouts/index.html file has basically the same except I’m doing {{ .Render "post"}}.

The Render method docs say that the input to render " should be a file name that points to a template in one of the locations specified in the documentation for Content Views". The first layout to be rendered is /layouts/<TYPE>/<VIEW>.html, so I made a layout /layouts/post/post.html.

Maybe the more standard way of doing this would be to create a layouts/post/list.html, which I did add as an experiment for a comment section, but that did not seem to work help get my homepage template working.

Since I wasn’t able to see all content in /content/post from the homepage (i.e /), I changed my /layouts/post/post.html. from {{.Content}} to

  {{ range .Pages }}
    {{ .Content }}
  {{ end }}

This render content from /content/posts/*.md locally from /. Yay! However, like I mentioned above I’m seeing the opposite results when deploying to Netlify.

{{.Content}} - Netlify link - test2 branch - All post content at /
{{ range .Pages }} ... - Netlify link - master branch - No post content at /

I totally understand if diving into deployment problems is out of scope for this forum, but I at least wanted to know which result is expected for how hugo version 0.59.1 is supposed to work.

Is your question why, on your homepage, you only get the content from the /post directory displaying?

If you want to use the .Render function on your homepage, you need to create a view for all your data types - see https://gohugo.io/templates/views/ Since you have /layouts/post/post.html that why /content/post is displaying but not /content/comment.

Hey @funkydan2.

Is your question why, on your homepage, you only get the content from the /post directory displaying?

No, it’s not. My goal is this.

What I was trying to do was get to get all post content to render from / using this type of snippet.

Sorry if mentioning content/comment made things confusing. I just added it as an alternative example of how to get a non-homepage template list template to work. My layout/index.html does not try to render any comment content so that would be another major problem if I was trying to have comment content at /.

Anyways the issue I mentioned I’m facing is my content view seems to render one way locally and another when deployed depending on how I have layout/post/post.html set up. Here’s another explanation that might be more clear.

When the layout/post/post.html file is {{.Content}}

  • Local: Displays no content from content/post/*md. Run test2 branch locally to confirm.
  • Deployed: Displays all content from content/post/*md. See Netlify link

When the layout/post/post.html file is {{ range .Pages }} {{ .Render "post"}} {{ end }} -

  • Local: Displays all content from content/post/*md. Checkout master branch and run hugo serve to confirm. This is my desired behavior and I’d expect the same behavior when deploying.
  • Deployed: Displays no content from content/post/*md. See Netlify link.

So my questions are:

  1. Can someone confirm that my layout/post/post.html file and code is the correct way to have content view rendered at /?
  2. Any tips for debugging deployment issues like this?

That builds are different locally and on Netlify is strange. However, I know that the behaviour of .Pages has changed in recent versions of Hugo.

Are you sure you’re running the same version of Hugo locally and on Netlify? You don’t have a netlify.toml files in your repo, so it’s hard for me to check. Have a look at the docs for an example configuration (just make sure you change the version numbers).

1 Like