# Trouble getting /posts files to show up on homepage

**URL:** <https://discourse.gohugo.io/t/trouble-getting-posts-files-to-show-up-on-homepage/43054>\
**Category:** support\
**Created:** [February 20, 2023, 3:28am UTC](https://discourse.gohugo.io/t/trouble-getting-posts-files-to-show-up-on-homepage/43054 "2023-02-20T03:28:42Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![anon29833707](https://avatars.discourse-cdn.com/v4/letter/a/b5e925/32.png) [@anon29833707](https://discourse.gohugo.io/u/anon29833707)\
**Post date:** [February 20, 2023, 3:28am UTC](https://discourse.gohugo.io/t/trouble-getting-posts-files-to-show-up-on-homepage/43054/1 "2023-02-20T03:28:42Z")

</div>

Dummy repository link: [Test-Site/Test at main · DrC0l0ssus/Test-Site · GitHub](https://github.com/DrC0l0ssus/Test-Site/tree/main/Test)

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](https://cloudcannon.com/community/learn/hugo-tutorial/content-and-blogging-in-hugo/)

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](https://discourse.gohugo.io/t/listing-blog-posts-on-homepage-not-working/30046/2) 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 }}

{{ .Date.Format "January 2, 2006" }}
{{ end }}

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!

---

<div class="post-metadata">

**Author:** ![jmooring](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/jmooring/32/4214_2.png) [@jmooring](https://discourse.gohugo.io/u/jmooring)\
**Post date:** [February 20, 2023, 7:12am UTC](https://discourse.gohugo.io/t/trouble-getting-posts-files-to-show-up-on-homepage/43054/2 "2023-02-20T07:12:44Z")

</div>

> [@anon29833707](#):
>
> I’ll share my relevant code snippets here if it helps

Not really.

You are more likely to receive an accurate and timely response if you post a link to the public repository for your project.

See [https://discourse.gohugo.io/t/requesting-help/9132](https://discourse.gohugo.io/t/requesting-help/9132).

> Let us see your code
> 
> Include a **link to the source code repository** of your project, because we really need the _context_ of seeing your templates and partials to be able to help you. It is trivial to do a quick `git clone` on your repo, then run `hugo server` in your project, to help you out. On the other hand, recreating your code from screenshots, or sort of guessing at it, is not.
> 
> If you can’t share your repository for whatever reason, consider creating a dummy repo that you _can_ share, which reproduces the problem you’re experiencing.

---

<div class="post-metadata">

**Author:** ![Arif](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/arif/32/20931_2.png) [@Arif](https://discourse.gohugo.io/u/Arif)\
**Post date:** [February 20, 2023, 9:10am UTC](https://discourse.gohugo.io/t/trouble-getting-posts-files-to-show-up-on-homepage/43054/3 "2023-02-20T09:10:59Z")

</div>

Try this in your index.html file.

```auto
{{ define "main" }}
<h1>{{ site.Title }}</h1>
<section class="">
    {{- $p := .Paginate (where site.RegularPages "Section" "posts") }}
    {{ range $p.Pages }}
    <article class="">
        <a class="" href="{{ .RelPermalink }}">{{ .LinkTitle }}</a>
    </article>
    {{- end }}
    {{- template "_internal/pagination.html" . }}
    </section>
{{- end }}

```

Do you need to add featured images?

---

<div class="post-metadata">

**Author:** ![anon29833707](https://avatars.discourse-cdn.com/v4/letter/a/b5e925/32.png) [@anon29833707](https://discourse.gohugo.io/u/anon29833707)\
**Post date:** [February 20, 2023, 2:28pm UTC](https://discourse.gohugo.io/t/trouble-getting-posts-files-to-show-up-on-homepage/43054/4 "2023-02-20T14:28:59Z")

</div>

Featured images - no, I don’t need to add them. I have a question about this line:

```auto
{{- template "_internal/pagination.html" . }}

```

Is a pagination file required if I want to paginate posts? The Cloudcannon article didn’t mention anything about it. Also, where would I put the \_internal file?

---

<div class="post-metadata">

**Author:** ![Arif](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/arif/32/20931_2.png) [@Arif](https://discourse.gohugo.io/u/Arif)\
**Post date:** [February 20, 2023, 3:01pm UTC](https://discourse.gohugo.io/t/trouble-getting-posts-files-to-show-up-on-homepage/43054/5 "2023-02-20T15:01:28Z")

</div>

That part covers pagination for you. You just now need to style it with some CSS.

> **[Internal Templates](https://gohugo.io/templates/internal/)**
>
> Hugo ships with a group of boilerplate templates that cover the most common use cases for static websites.

---

<div class="post-metadata">

**Author:** ![anon29833707](https://avatars.discourse-cdn.com/v4/letter/a/b5e925/32.png) [@anon29833707](https://discourse.gohugo.io/u/anon29833707)\
**Post date:** [February 20, 2023, 6:01pm UTC](https://discourse.gohugo.io/t/trouble-getting-posts-files-to-show-up-on-homepage/43054/6 "2023-02-20T18:01:30Z")

</div>

I edited my post, but here’s a dummy repository link: [Test-Site/Test at main · DrC0l0ssus/Test-Site · GitHub](https://github.com/DrC0l0ssus/Test-Site/tree/main/Test)

I removed some files/folders from “content” that aren’t relevant to this problem, so I’m focusing solely on “posts”. Let me know if you have trouble viewing the files, I haven’t had a GitHub account until now so I’m not used to using it.

---

<div class="post-metadata">

**Author:** ![anon29833707](https://avatars.discourse-cdn.com/v4/letter/a/b5e925/32.png) [@anon29833707](https://discourse.gohugo.io/u/anon29833707)\
**Post date:** [February 20, 2023, 6:03pm UTC](https://discourse.gohugo.io/t/trouble-getting-posts-files-to-show-up-on-homepage/43054/7 "2023-02-20T18:03:33Z")

</div>

Adding the code you suggested alone doesn’t seem to do anything - I edited my initial post to include a dummy repository here: [Test-Site/Test at main · DrC0l0ssus/Test-Site · GitHub](https://github.com/DrC0l0ssus/Test-Site/tree/main/Test)

I got rid of some irrelevant folders/files from “content” as they’re just sub-pages, but let me know if you have trouble accessing the files or getting them to work. I’m new to GitHub, so let me know if I borked anything. Thanks!

---

<div class="post-metadata">

**Author:** ![jmooring](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/jmooring/32/4214_2.png) [@jmooring](https://discourse.gohugo.io/u/jmooring)\
**Post date:** [February 20, 2023, 7:39pm UTC](https://discourse.gohugo.io/t/trouble-getting-posts-files-to-show-up-on-homepage/43054/8 "2023-02-20T19:39:18Z")

</div>

Looking through your example, it seems like it might be easier for you to start with something that you can easily learn from. So, instead of fixing what you already have, have a look at this:

```auto
git clone --single-branch -b hugo-forum-topic-43054 https://github.com/jmooring/hugo-testing hugo-forum-topic-43054
cd hugo-forum-topic-43054
hugo server

```

This is a very basic skeleton.

---

<div class="post-metadata">

**Author:** ![Arif](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/arif/32/20931_2.png) [@Arif](https://discourse.gohugo.io/u/Arif)\
**Post date:** [February 20, 2023, 7:39pm UTC](https://discourse.gohugo.io/t/trouble-getting-posts-files-to-show-up-on-homepage/43054/9 "2023-02-20T19:39:26Z")

</div>

1. Your markdown posts don’t have a `title` field.
2. Your layout structure is wrong. `index.html` should be in the root of `layouts` folder.
3. Run the server command with `hugo server -D` when you have `draft: true` set.
4. Include an `_index.md` file in the root of the `content` folder.
5. Follow @jmooring 's example as he recommends.

---

<div class="post-metadata">

**Author:** ![anon29833707](https://avatars.discourse-cdn.com/v4/letter/a/b5e925/32.png) [@anon29833707](https://discourse.gohugo.io/u/anon29833707)\
**Post date:** [February 20, 2023, 9:02pm UTC](https://discourse.gohugo.io/t/trouble-getting-posts-files-to-show-up-on-homepage/43054/10 "2023-02-20T21:02:15Z")

</div>

Thanks. I moved the files you mentioned in steps 2 and 4. As for 1, is the `title` field required? I assumed it wasn’t, and I wasn’t planning on having titles with my posts. Is it possible to disable the title field (aside from not including them)?

Once I followed steps 1 - 4, I got the post titles to show up on the homepage. I’d like to just have the entire posts show up on the homepage instead of summaries and save clicks, but I’ll look into @jmooring’s example and follow up with him on his post to keep the conversation in their respective lanes here.

---

<div class="post-metadata">

**Author:** ![anon29833707](https://avatars.discourse-cdn.com/v4/letter/a/b5e925/32.png) [@anon29833707](https://discourse.gohugo.io/u/anon29833707)\
**Post date:** [February 20, 2023, 9:16pm UTC](https://discourse.gohugo.io/t/trouble-getting-posts-files-to-show-up-on-homepage/43054/11 "2023-02-20T21:16:04Z")

</div>

Thanks, I got the example downloaded and set up. It’s definitely different than how I have my site set up.

@Arif 's post below got me started with getting my posts visible on my home page, but it only shows the titles by default. What I’m interested in with the posts are two things:

1. Are titles required? I plan to post just an image or two at a time, with maybe a couple sentences for each post and the date.

2. Can I skip the summary and just have the entire posts show up on the homepage to save users some clicks?

---

<div class="post-metadata">

**Author:** ![Arif](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/arif/32/20931_2.png) [@Arif](https://discourse.gohugo.io/u/Arif)\
**Post date:** [February 20, 2023, 9:41pm UTC](https://discourse.gohugo.io/t/trouble-getting-posts-files-to-show-up-on-homepage/43054/13 "2023-02-20T21:41:06Z")

</div>

> [@anon29833707](#):
>
> Are titles required?

How will you differentiate between posts without titles? Remember titles are also used by search engines and social media open graph tags.

> [@anon29833707](#):
>
> Can I skip the summary and just have the entire posts show up on the homepage to save users some clicks?

Replace the code in `index.html` (or `home.html` whichever file name you choose) with the following

```auto
{{ define "main" }}
  {{ range (where site.RegularPages "Section" "posts").ByDate.Reverse }}
    <h2>{{ .Title }}</h2>
    {{ .Content }}
  {{ end }}
{{ end }}

```

---

<div class="post-metadata">

**Author:** ![jmooring](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/jmooring/32/4214_2.png) [@jmooring](https://discourse.gohugo.io/u/jmooring)\
**Post date:** [February 20, 2023, 9:56pm UTC](https://discourse.gohugo.io/t/trouble-getting-posts-files-to-show-up-on-homepage/43054/14 "2023-02-20T21:56:06Z")

</div>

> [@Arif](#):
>
> ```auto
> {{ range (where site.RegularPages "Section" "posts").ByDate.Reverse }}
> <h2>{{ .Title }}</h2>
> {{ .Content }}
> {{ end }}
> 
> ```

If you content files contain link or image destinations that are relative to the content page, the links and images will be broken when the content is rendered in another context (e.g., home page, list page).

You need to use markdown render hooks to resolve these to the site root.

---

<div class="post-metadata">

**Author:** ![anon29833707](https://avatars.discourse-cdn.com/v4/letter/a/b5e925/32.png) [@anon29833707](https://discourse.gohugo.io/u/anon29833707)\
**Post date:** [February 20, 2023, 10:34pm UTC](https://discourse.gohugo.io/t/trouble-getting-posts-files-to-show-up-on-homepage/43054/15 "2023-02-20T22:34:36Z")

</div>

> [@Arif](#):
>
> How will you differentiate between posts without titles? Remember titles are also used by search engines and social media open graph tags.

Good point. This wasn’t a must-have setting on my end, I just figured it wasn’t worth having b/c I’d probably spend more time thinking of a title than putting a post together. I’ll live. 😄

---

<div class="post-metadata">

**Author:** ![anon29833707](https://avatars.discourse-cdn.com/v4/letter/a/b5e925/32.png) [@anon29833707](https://discourse.gohugo.io/u/anon29833707)\
**Post date:** [February 20, 2023, 10:38pm UTC](https://discourse.gohugo.io/t/trouble-getting-posts-files-to-show-up-on-homepage/43054/16 "2023-02-20T22:38:01Z")

</div>

Mine will definitely contain images, and possibly links. In your example site you sent me, I know post 15 has an image and is set up as a leaf bundle, so I’ll probably use that as a template or an example for how to structure my posts. Not sure if using markdown render hooks is a separate issue or not, so let me know if I’m on the right train of thought there or if I need to do something else.
