Hello.
This is my Day 1 in Hugo and I’ve made some self-satisfactory progress by reading a lot of posts on these forums, documentation, GitHub and others’ blogs. However, now, I’ stuck at a point for which I don’t seem to be getting an answer.
Basically, for organization purposes, I’m willing to add all my posts in content/posts
directory. However, on the home page, I’d like to directly display the posts list instead of displaying the link to posts
directory first and then the actual post.
Here’s what I’ve done (the snippets have been truncated to show only the bare layout of the HTML so as to not create a mess in this post):
layouts/default/baseof.html
:
<!DOCTYPE html>
<html lang = "en">
<head>
<!-- Styles and scripts -->
</head>
<body>
{{ block "main" . }}
{{ end }}
</body>
</html>
layouts/index.html
:
{{ define "main" }}
{{ range where .Data.Pages "Section" "posts" }}
<a href = "{{.RelPermalink}}">{{ .Title }}</a>
{{ end }}
{{ end }}
So, as I said before, even after (probably) filtering out posts only from the section (contents/posts/
) on the home page, I am still seeing the link to the directory and not to the post. What am I missing?
Just to be clear, I’m not using any pre-built theme, I’m experimenting myself.