# \[SOLVED\] One page that list ALL posts

**URL:** <https://discourse.gohugo.io/t/solved-one-page-that-list-all-posts/6086>\
**Category:** support\
**Created:** [April 9, 2017, 9:22pm UTC](https://discourse.gohugo.io/t/solved-one-page-that-list-all-posts/6086 "2017-04-09T21:22:59Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![diegoeis](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/diegoeis/32/2959_2.png) [@diegoeis](https://discourse.gohugo.io/u/diegoeis)\
**Post date:** [April 9, 2017, 9:22pm UTC](https://discourse.gohugo.io/t/solved-one-page-that-list-all-posts/6086/1 "2017-04-09T21:22:59Z")

</div>

Hi,

I want to create one page, that list all posts of website. Example: if I visit `localhost:1313/all-posts/` this page shows all posts in the website.

---

<div class="post-metadata">

**Author:** ![rdwatters](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/rdwatters/32/2848_2.png) [@rdwatters](https://discourse.gohugo.io/u/rdwatters)\
**Post date:** [April 9, 2017, 9:36pm UTC](https://discourse.gohugo.io/t/solved-one-page-that-list-all-posts/6086/2 "2017-04-09T21:36:59Z")

</div>

**[EDITED PER BEP’S OBSERVATION BELOW]**

Create the following layout at `layouts/section/all-posts.html`

```auto
{{ define "main" }}
{{.Content}}
<ul class="all-posts">
{{range .Site.RegularPages}}
<li><a href="{{.Permalink}}">{{.Title}}</a></li>
{{end}}
</ul>
{{ end }}

```

**Note:** The `{{.Content}}` in the above example will pull from the content file you have at `content/all-posts/_index.md`.

If you are talking about putting it in any other layout, you can always use `.Site.Pages` to grab all the pages (including `_index.md` in each section) or `.Site.RegularPages`, which grabs all pages except `_index.md`…

---

<div class="post-metadata">

**Author:** ![bep](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/bep/32/3332_2.png) [@bep](https://discourse.gohugo.io/u/bep)\
**Post date:** [April 9, 2017, 10:09pm UTC](https://discourse.gohugo.io/t/solved-one-page-that-list-all-posts/6086/3 "2017-04-09T22:09:37Z")

</div>

I guess what he asks for is better accomplished with:

1. Template in /layouts/section/all-posts.html with `{{range .Site.RegularPages }}`
2. A content page in /all-posts/\_index.md

---

<div class="post-metadata">

**Author:** ![diegoeis](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/diegoeis/32/2959_2.png) [@diegoeis](https://discourse.gohugo.io/u/diegoeis)\
**Post date:** [April 11, 2017, 1:47am UTC](https://discourse.gohugo.io/t/solved-one-page-that-list-all-posts/6086/4 "2017-04-11T01:47:14Z")

</div>

> [@rdwatters](#):
>
> {{ define “main” }}  
> {{.Content}}  
> \<ul class=“all-posts”\>  
> {{range .Site.RegularPages}}  
> \<li\>\<a href=“{{.Permalink}}”\>{{.Title}}\</a\>\</li\>  
> {{end}}  
> \</ul\>  
> {{ end }}

@rdwatters this does not work properly.  
 ![](https://canada1.discourse-cdn.com/flex036/uploads/gohugo/original/2X/6/65510880c1ccdc669ff563cba26b39582df317a0.png)

 ![](https://canada1.discourse-cdn.com/flex036/uploads/gohugo/original/2X/a/ae821b714a6a36ad668c064eff4071fd17fd4227.png)

So, I tried the @bep solution and this works fine.

I confess I don’t understand why I need to create a section instead create a simple `.html` in content with `.Site.RegularPages`.

* * *

Another question: when I put the posts inside `content/posts`, the URL looks like `http://mydomain.com/posts/name-of-post/`.  
How can I make the URL looks like `http://mydomain.com/name-of-post/` (without the `/posts/`) and maintain the posts inside the `content/posts/` folder?

Guys, I really appreciated your help.

---

<div class="post-metadata">

**Author:** ![rdwatters](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/rdwatters/32/2848_2.png) [@rdwatters](https://discourse.gohugo.io/u/rdwatters)\
**Post date:** [April 11, 2017, 3:32am UTC](https://discourse.gohugo.io/t/solved-one-page-that-list-all-posts/6086/5 "2017-04-11T03:32:46Z")

</div>

> [@diegoeis](#):
>
> @rdwatters this does not work properly.

It’s the same thing that @bep wrote after I put my edit in it 😉

A screenshot of your project will not help me much, but I’m glad it’s working now.

One thing to check is whether you are using block/base templates. If you’re not, then `{{define "main"}}` doesn’t mean anything. Also, judging by the highlighting in your screenshot, it looks like you put the `all-posts.html` in `content/posts`, but it needs to be in your layouts folder, which now helps me understand the following:

> [@diegoeis](#):
>
> I confess I don’t understand why I need to create a section instead create a simple .html in content with .Site.RegularPages.

`.Site.RegularPages` is part of templating and not part of content.

> [@diegoeis](#):
>
> How can I make the URL looks like [http://mydomain.com/name-of-post/](http://mydomain.com/name-of-post/)

By “name,” do you want the title or slug? In your site’s config.toml, the following will give you the URL you want:

```toml
[permalinks]
  posts = "/:title"

```

OR…

```toml
[permalinks]
  posts = "/:slug"

```

---

<div class="post-metadata">

**Author:** ![Hash\_Borgir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/hash_borgir/32/6655_2.png) [@Hash\_Borgir](https://discourse.gohugo.io/u/Hash_Borgir)\
**Post date:** [April 11, 2017, 12:09pm UTC](https://discourse.gohugo.io/t/solved-one-page-that-list-all-posts/6086/6 "2017-04-11T12:09:40Z")

</div>

I advise :slug.

---

<div class="post-metadata">

**Author:** ![diegoeis](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/diegoeis/32/2959_2.png) [@diegoeis](https://discourse.gohugo.io/u/diegoeis)\
**Post date:** [April 13, 2017, 1:59am UTC](https://discourse.gohugo.io/t/solved-one-page-that-list-all-posts/6086/7 "2017-04-13T01:59:53Z")

</div>

@rdwatters Great! `posts = "/:filename"` works like a charm!

Thanks to you and @bep for all help.  
Yesterday I just finished to migrate all my website with more than 1650 posts and multiples authors to Hugo.  
You can check it here: [https://tableless.com.br/](https://tableless.com.br/)

Thx! \o/

---

<div class="post-metadata">

**Author:** ![justshipit](https://avatars.discourse-cdn.com/v4/letter/j/e56c9b/32.png) [@justshipit](https://discourse.gohugo.io/u/justshipit)\
**Post date:** [January 19, 2022, 9:21am UTC](https://discourse.gohugo.io/t/solved-one-page-that-list-all-posts/6086/8 "2022-01-19T09:21:09Z")

</div>

> [@bep](#):
>
> /all-posts/\_index.md

Where should the `/all-posts/_index.md` go exactly? Inside `layouts` dir? I can’t make it to work any way I try.

---

<div class="post-metadata">

**Author:** ![alexandros](https://avatars.discourse-cdn.com/v4/letter/a/ecc23a/32.png) [@alexandros](https://discourse.gohugo.io/u/alexandros)\
**Post date:** [January 19, 2022, 10:38am UTC](https://discourse.gohugo.io/t/solved-one-page-that-list-all-posts/6086/9 "2022-01-19T10:38:57Z")

</div>

You are asking a question in a topic that was solved 5 years ago.

Please read the forum guidelines:

> [@Help keep this forum practical](https://discourse.gohugo.io/t/help-keep-this-forum-practical/31644):
>
> This is a reminder about how users can do their part and help keep this forum as a useful resource about Hugo. Users really need to stop bumping old topics from many years ago. Instead it is recommended that they open a new topic with a link to an old topic when they need to reference it. Users need to read the [Forum FAQ](https://discourse.gohugo.io/faq) and the [Requesting Help](https://discourse.gohugo.io/t/requesting-help/9132) guidelines before opening their first topic. Users need to be courteous at all times. Users need to be On Topic and that topic is only Hugo and how som…

---

<div class="post-metadata">

**Author:** ![alexandros](https://avatars.discourse-cdn.com/v4/letter/a/ecc23a/32.png) [@alexandros](https://discourse.gohugo.io/u/alexandros)\
**Post date:** [January 19, 2022, 10:39am UTC](https://discourse.gohugo.io/t/solved-one-page-that-list-all-posts/6086/10 "2022-01-19T10:39:02Z")

</div>


