# Showing all articles in a single page

**URL:** <https://forum.ghost.org/t/showing-all-articles-in-a-single-page/19588>\
**Category:** Routing\
**Created:** [January 19, 2021, 4:06pm UTC](https://forum.ghost.org/t/showing-all-articles-in-a-single-page/19588 "2021-01-19T16:06:35Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![iamarup](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/iamarup/32/11280_2.png) [@iamarup](https://forum.ghost.org/u/iamarup)\
**Post date:** [January 19, 2021, 4:06pm UTC](https://forum.ghost.org/t/showing-all-articles-in-a-single-page/19588/1 "2021-01-19T16:06:36Z")

</div>

Hi,

How to show all blog posts in a page? I mean a single page which will display all articles/blog posts available in the ghost blog.

What’ll be the code for doing that?

Ghost Version: 3.40.5  
Debian 10.7 Stable

---

<div class="post-metadata">

**Author:** ![pieter](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/pieter/32/11499_2.png) [@pieter](https://forum.ghost.org/u/pieter)\
**Post date:** [January 19, 2021, 8:31pm UTC](https://forum.ghost.org/t/showing-all-articles-in-a-single-page/19588/2 "2021-01-19T20:31:29Z")

</div>

This is possible by creating an additional template file in your theme and pointing the `routes.yaml` file to it.

So, let’s suppose you create the following file in your theme: `all-posts.hbs`

Containing something similar to this:

```auto
{{!< default}}

{{#get "posts" limit="all"}}
    {{#foreach posts}}
        
<article class="{{post_class}}">
  <header class="post-header">
    <h1 class="post-title">{{title}}</h1>
    <section class="post-meta">
      <time class="post-date" datetime="{{date format='YYYY-MM-DD'}}">
        {{date format="DD MMMM YYYY"}}
      </time>
      {{tags prefix=" on "}}
    </section>
  </header>
  <section class="post-content">
    {{content}}
  </section>
</article>

    {{/foreach}}
{{/get}}

```

Now in your `routes.yaml` set the URL:

```auto
## routes.yaml

routes:
  /all-posts/: all-posts

```

---

<div class="post-metadata">

**Author:** ![iamarup](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/iamarup/32/11280_2.png) [@iamarup](https://forum.ghost.org/u/iamarup)\
**Post date:** [January 20, 2021, 6:25am UTC](https://forum.ghost.org/t/showing-all-articles-in-a-single-page/19588/3 "2021-01-20T06:25:13Z")

</div>

It’s not working. I am using a custom theme, not default one called ‘Casper’.  
I have created “all-posts.hbs” under that theme with your given contents and also edited ‘routes.yaml’ file. After that I restart the ghost process:

> ghost restart

when I go to **localhost:2368/all-posts/**  
it’s saying 404 Error, page not found.

Here’s my theme tree and the contents of “all-posts.hbs”

 ![Capture](https://us1.discourse-cdn.com/flex015/uploads/ghost2/original/2X/9/9e8ebb36991123ea4d5411f36ee3f6c77d6a8590.png)

---

<div class="post-metadata">

**Author:** ![pieter](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/pieter/32/11499_2.png) [@pieter](https://forum.ghost.org/u/pieter)\
**Post date:** [January 20, 2021, 7:04am UTC](https://forum.ghost.org/t/showing-all-articles-in-a-single-page/19588/4 "2021-01-20T07:04:01Z")

</div>

That is strange, I tested it here on a local install too and it works.

Are you sure you uploaded the `routes.yaml` correctly under Settings \> Labs \> Routes?

Can you share a screenshot of your `routes.yaml`? Just to check nothing funky is going on in there

---

<div class="post-metadata">

**Author:** ![iamarup](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/iamarup/32/11280_2.png) [@iamarup](https://forum.ghost.org/u/iamarup)\
**Post date:** [January 20, 2021, 7:35am UTC](https://forum.ghost.org/t/showing-all-articles-in-a-single-page/19588/5 "2021-01-20T07:35:22Z")

</div>

Yes, I have edited my current routes.yaml with required line and it saved under /content/settings/ folder.

Here’s the contents of that file:

```
routes:

collections:

  /:

    permalink: /{slug}/

    template: index

taxonomies:

  tag: /tag/{slug}/

  author: /author/{slug}/

/all-posts: all-posts

```

Anything wrong here?

---

<div class="post-metadata">

**Author:** ![iamarup](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/iamarup/32/11280_2.png) [@iamarup](https://forum.ghost.org/u/iamarup)\
**Post date:** [January 20, 2021, 8:01am UTC](https://forum.ghost.org/t/showing-all-articles-in-a-single-page/19588/6 "2021-01-20T08:01:27Z")

</div>

One more thing plz. I have tested this page by using custom page template and creating a new page with that template.  
Text and headline alignment are not perfectly matching with the screen. Too much aligned to left of the screen. Check screenshot:

 ![Capture](https://us1.discourse-cdn.com/flex015/uploads/ghost2/original/2X/2/20291429b6aab6f6d9507b6b09c2749bcbfb9ffa.png)

How to align those on center?

---

<div class="post-metadata">

**Author:** ![pieter](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/pieter/32/11499_2.png) [@pieter](https://forum.ghost.org/u/pieter)\
**Post date:** [January 20, 2021, 9:12am UTC](https://forum.ghost.org/t/showing-all-articles-in-a-single-page/19588/7 "2021-01-20T09:12:17Z")

</div>

Yup, you did not follow the YAML syntax requirements. This should do the trick, edit the file, upload it and restart Ghost:

```
routes:
   /all-posts/: all-posts

collections:
  /:
    permalink: /{slug}/
    template: index

taxonomies:
  tag: /tag/{slug}/
  author: /author/{slug}/
```

---

<div class="post-metadata">

**Author:** ![pieter](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/pieter/32/11499_2.png) [@pieter](https://forum.ghost.org/u/pieter)\
**Post date:** [January 20, 2021, 9:16am UTC](https://forum.ghost.org/t/showing-all-articles-in-a-single-page/19588/8 "2021-01-20T09:16:58Z")

</div>

That’s a whole new question.

Text alignment is configured via HTML or CSS. There are so many ways to achieve it:

- Utilize the dedicated HTML element: `<center> your text goes here </center>`
- Set `text-align` property of the containing element [https://www.w3schools.com/cssref/pr\_text\_text-align.ASP](https://www.w3schools.com/cssref/pr_text_text-align.ASP)
- Set the `margin-left` and `margin-right` properties of the containing element
- Utilize some kind of CSS library that has build in text alignment functions [Text · Bootstrap](https://getbootstrap.com/docs/4.0/utilities/text/)

---

<div class="post-metadata">

**Author:** ![iamarup](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/iamarup/32/11280_2.png) [@iamarup](https://forum.ghost.org/u/iamarup)\
**Post date:** [January 20, 2021, 9:40am UTC](https://forum.ghost.org/t/showing-all-articles-in-a-single-page/19588/9 "2021-01-20T09:40:11Z")

</div>

It solved the issue, many thanks.
