Dummy repository link: Test-Site/Test at main · DrC0l0ssus/Test-Site · GitHub
I’m in the midst of learning Hugo and creating a site from scratch with the HTML and CSS files I’ve created so far. Cloudcannon has a pretty good explainer series on how to use Hugo, but I’m getting tripped up on the weblog part: Content and blogging in Hugo | CloudCannon
I want to put my posts on the homepage instead of a separate section, but I’m trying to reverse-engineer Cloudcannon’s process and am not having any luck so far.
I don’t have the files on any repository to easily share, so I’ll share my relevant code snippets here if it helps show where I’m at. Right now, my baseof.html file looks like this:
<!DOCTYPE html>
<html lang="en-us">
<head>
{{ partial "header.html" . }}
</head>
<body>
{{ partial "navbar.html" . }}
<main>
{{ block "main" . }}
{{ end }}
</main>
<footer>
{{ partial "footer.html" . }}
</footer>
</body>
</html>
index.html in my “layouts” folder looks like this:
{{ define "main" }}
<h1>(arbitrary header - for some reason my footer doesn't appear if I don't have this here, but otherwise this should be optional)</h1>
<p>{{ .Content }}</p>
{{ end }}
list.html in my “/layouts/posts” folder (and in my /_default folder - I wasn’t sure if the changes would work there) looks like this:
{{ define “main” }}
{{ range (.GetPage “/posts”).Pages }}
{{ end }}
{{ end }}
(I got that 2nd line of code from here: Listing blog posts on homepage not working - #2 by pointyfar but it didn’t seem to fix my problem, FYI.)
single.html in /layouts/posts folder looks like this. I changed the code from Cloudcannon’s example by removing all the HTML except for the date div class (though I’m not sure I even need the div class part, I think I just need the line, right?).
{{ define “main” }}
{{ .Content }}
Changing “draft” to “false” in my posts’ front matter (the Markdown files) didn’t change anything either.
I’m sure I’m missing something but I’m at a loss to figure out what it is. Any help would be appreciated, and if you need to see what my code is on other pages or where I have other files located, I’m happy to explain that too. Apologies for the long post, and thank you in advance!
P.S. - If anyone also has a clue as to why my footer disappears unless I have an h1 title in my index.html page, I’d appreciate any help there too - minor issue but it’s also throwing me for a loop!