[Solved] Can't link/render posts in 'content/posts' in new theme from scratch

Hi there, I seem to have trouble linking posts in my template.

I placed test posts (copied from a theme) into ‘content/posts’ directory.
dir

Then added to my config.toml as per in the URL Management docs.

[permalinks]
  posts = "/:year/:month/:title/"

This is how the template looks like.

<ul>
    {{ range after 1 .Pages.ByDate.Reverse }}
        <li>
            <a href="{{ .Permalink }}" class="with-hover-effect">
                <span>{{ .Title }}</span>
                <span class="hover-bar"></span>
            </a>
        </li>
    {{ end }}
</ul>

And I’m getting URLs like these which seems right but gives me 404s.

http://localhost:1313/2014/09/creating-a-new-theme/
http://localhost:1313/2014/04/getting-started-with-hugo/
http://localhost:1313/2014/04/hugo-template-primer/
http://localhost:1313/2014/03/migrate-from-jekyll/

Edit: So, I quickly downloaded a random theme (minimal) and built the site, compared and noticed the issue. My theme doesn’t seem to be outputting any posts while the other theme had a ‘public > 2014’ folder.

build

Hugo version

Hugo Static Site Generator v0.55.0-DEV/extended windows/amd64 BuildDate: unknown

Solution

There was no error in the console even with --verbose, after an hour of looking and fiddling, turned out I needed at least some code in single.html for it to even render anything. I just threw in {{ .Content }} and worked from thereon.

1 Like