HUGO

Content only appears after modifying content files

When I run hugo server the frontpage displays, but other pages do not until I have modified the corresponding index file; so content/map/index.md needs to be modified before the /map/ page will display. If I run hugo --cleanDestinationDir --minify to deploy the site, these pages also don’t get written to.

My content dir has:
├── articles
│ ├── 2020-04-30-some-article.md
│ └── index.md
├── contact
│ └── index.md
├── index.md
└── map
└── index.md

My layouts dir:
├── _default
│ ├── baseof.html
│ ├── single.html
│ └── tag.html
├── partials
│ ├── nav_item.html
│ └── posts_list.html
└── shortcodes
├── base_url.html
└── partial.html

I get a warning when I first run hugo server:

WARN 2020/06/29 08:10:59 found no layout file for "HTML" for kind "home": You should create a template file which matches Hugo Layouts Lookup Rules for this combination

But I can make that error go away by adding an empty layouts/_default/home.html - and that doesn’t solve the problem. Any help would be greatly appreciated, I am stumped - I would’ve thought that hugo server and simply hugo should create the same pages at all times.

Hi …

could you have added type: home to one of your markdown content files?

This would result in looking for an HTML layout for ‘home’

No, I have not. Do you think it matters for the problem at hand? I can make that error go away by adding an empty layouts/_default/home.html - and that doesn’t solve the problem.

Hi

And what about the markdown files in /content/maps/ and content/contact/

somewhere in your markdown files it is saying to use the home template

Also check your theme examplesite folder and see if there is a template there

None of the markdown files specify a type.

I’m not using a theme at all. Since I already had a css file to work from, I didn’t see any point. I was following this themeless gitless hugo tutorial.

Then contact the author … about step 15

2020-June-25 Updated step 15. Explore the layouts directory below so it uses the new Hugo v0.73.0+ .Kind terminology.

@TamaMcGlinn, you appear to missing a list.html file in your layouts/_default directory. When troubleshooting issues such as these it is far more efficient to post a link to a public repository for your project.

From the tutorial you’ve been using…

See the list.html file?

Creating an empty list.html and home.html does not change the behaviour of this bug. You make a valid point; I should make a minimal reproducer. I’ve been trying to do that this week, but when removing my site-specific content I don’t wish to share, the problem sometimes disappears.

Ok, I have a minimal reproducer now;

git clone git@github.com:TamaMcGlinn/hugo-tutorial.git
cd hugo-tutorial
hugo server

visit the link given, and observe that clicking either about or contact yields a 404. But now modify content/about/index.md (even whitespace in the yaml frontmatter that won’t matter) and observe that the link works.

Required changes:

  1. Rename content/index.md to content/_index.md

  2. In content/_index.md change page_title: Home to title: Home

  3. Create layouts/_default/list.html, something like this:

    {{ define "main" }}
      <h1>{{ .Title }}</h1>
      {{ .Content }}
      {{ range .Site.RegularPages }}
        <article>
          <h2><a href="{{ .RelPermalink }}">{{ .Title }}</a></h2>
          {{ .Summary }}
        </article>
      {{ end }}
    {{ end }}
    

Opinionated changes:

  1. In layouts/_default/single.html, use this construct to build the tag list:

    <ul>
      {{ range (.GetTerms "tags") }}
        <li><a href="{{ .Permalink }}">{{ .LinkTitle }}</a></li>
      {{ end }}
    </ul>
    
  2. When specifying a date in front matter, use this format: 2020-06-30T08:43:35-04:00. You may not need it now, but you may later on.

  3. Use TOML instead of YAML for front matter format. With TOML, dates are first class citizens. This is not true for YAML or JSON, and using TOML from the outset may make your life easier later on.

Thank you, that fixed the problem. Thanks extra for the other suggestions, I’ve implemented them all.

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