# Replace homepage with an index from certain section?

**URL:** <https://discourse.gohugo.io/t/replace-homepage-with-an-index-from-certain-section/8126>\
**Category:** Uncategorized\
**Created:** [August 25, 2017, 9:19pm UTC](https://discourse.gohugo.io/t/replace-homepage-with-an-index-from-certain-section/8126 "2017-08-25T21:19:34Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Killy](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/killy/32/642_2.png) [@Killy](https://discourse.gohugo.io/u/Killy)\
**Post date:** [August 25, 2017, 9:19pm UTC](https://discourse.gohugo.io/t/replace-homepage-with-an-index-from-certain-section/8126/1 "2017-08-25T21:19:34Z")

</div>

I have a blog, with `post` being the main section and other stuff not listed on the homepage.

For homapage I’m currently using custom paginator:

```auto
{{ $paginator := .Paginate (where .Data.Pages "Section" "post") }}

```

I have two issues with it:

- It’s just a copy of some section index, made in more awkward way, and that section index still exists on its own, essentially unused in the site design;
- Custom paginator leads to some theming limitations - I can’t pass it from redefined block to base in order to use in multiple places, so I have to reorganize my theme significantly.

Ideal solution for me would be like this:  
In `config.toml` I set something like

```auto
homeSection = "post"

```

As the result, `example.org/post/` index page will have permalink `example.org/` instead. And `layouts/index.html` will not be used as unneeded entity.

Other, not as clean way to solve my issue would be to provide a way to set which sections are present in homepage `.Data.Pages` array, so I could leave it with default paginator.

UPD: opened an issue/request - [https://github.com/gohugoio/hugo/issues/3838](https://github.com/gohugoio/hugo/issues/3838)

---

<div class="post-metadata">

**Author:** ![maiki](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/maiki/32/16384_2.png) [@maiki](https://discourse.gohugo.io/u/maiki)\
**Post date:** [August 26, 2017, 9:32pm UTC](https://discourse.gohugo.io/t/replace-homepage-with-an-index-from-certain-section/8126/2 "2017-08-26T21:32:05Z")

</div>

I don’t think this is a common issue for folks, while having a custom homepage is _very_ common.

One random thought: do you need pagination on the front page?

What I mean is: do your site visitors click on page 3 or 6 from the front page? Or do they just go to the second page of posts? Why not just have a single link to the second page of paginated `post`? Then you just need to make sure the front page shows the same amount of posts as the first page of `/post`.

> [@Killy](#):
>
> Custom paginator leads to some theming limitations - I can’t pass it from redefined block to base in order to use in multiple places, so I have to reorganize my theme significantly.

That sounds like a interesting discussion, if you can describe how this affects theme or site creators.

---

<div class="post-metadata">

**Author:** ![Killy](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/killy/32/642_2.png) [@Killy](https://discourse.gohugo.io/u/Killy)\
**Post date:** [August 26, 2017, 10:57pm UTC](https://discourse.gohugo.io/t/replace-homepage-with-an-index-from-certain-section/8126/3 "2017-08-26T22:57:23Z")

</div>

> [@maiki](#):
>
> I don’t think this is a common issue for folks, while having a custom homepage is very common.

I think it’s common to have a blog that have no special frontpage - and goes straight to recent posts.  
I should emphasize: I’m not talking about getting rid of custom frontpage completely. But I need a way to replace it with full-featured section **if needed**.

> [@maiki](#):
>
> do your site visitors click on page 3 or 6 from the front page? Or do they just go to the second page of posts? Why not just have a single link to the second page of paginated post?

Yes, I need full pagination on homepage. Pagination across posts. I need my homepage **to be** the `post` section, actually. The way of faking it you proposed just shows that maybe I did a bad job in explaining the issue - it’s a move in a wrong direction.  
I could rather pretend that `example.org/post/` is my homepage and redirect from homepage to there, but that’s ugly. I don’t want to have links of a form `example.org/post/page/2` anywhere.  
`example.org/page/2` should be the second page of my blog.

Currently I’m achieving required behaviour by custom paginator as mentioned in the opening post. There are some unused pages generated (original index from `post` section), but that’s not a big deal. It was good enough for me until recently, when I tried to access the pagination from base layout.  
Default paginator is available from global context. For a paginator defined in some concrete layout, I see no way to access it from baseof layout.  
I could reorganize my theme to move more stuff into concrete layouts (into concrete block definitions), but running into this issue let me to think about the root cause of the issue.  
And the root issue - I have to fake `post` section in the homepage instead of having it there.

> [@maiki](#):
>
> if you can describe how this affects theme or site creators.

So, there is a new parameter for site config, called `homeSection`. If it is not set, there is no changes for theme and site creator at all.  
And if it is set to some section name, then that section index will be created at the root of site instead of usual location. Homepage template (`layouts/index.html`) is not needed in this case, as its’ place is filled already.

Theme creators may or may not design around this use case - that means including `layouts/index.html` into theme or not.  
Let’s say site creator has a fully-featured theme at hands. He may use it in the way it works now, or he may set the `homeSection` parameter and promote that section to be homepage instead of what’s defined by theme.

If there is a theme without `layouts/index.html`, then, depending on the presence of `homeSection` parameter, homepage will either use default list layout to show all the site pages (if parameter is not set) or will use whatever layout is set for that section to show that section pages (if parameter is set).

---

<div class="post-metadata">

**Author:** ![maiki](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/maiki/32/16384_2.png) [@maiki](https://discourse.gohugo.io/u/maiki)\
**Post date:** [August 27, 2017, 2:02am UTC](https://discourse.gohugo.io/t/replace-homepage-with-an-index-from-certain-section/8126/4 "2017-08-27T02:02:48Z")

</div>

Reading all that, it sounds like what you want is the paginator working in the base templates, correct? As in, if that worked your problem would be solved, ne?

I haven’t personally dealt with pagination much, but I’d like to see your templates. As a thought exercise I don’t think I would want pagination in a base template, so I’d like to see your working example to find how it all fits together. 🙂

---

<div class="post-metadata">

**Author:** ![Killy](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/killy/32/642_2.png) [@Killy](https://discourse.gohugo.io/u/Killy)\
**Post date:** [August 27, 2017, 10:31am UTC](https://discourse.gohugo.io/t/replace-homepage-with-an-index-from-certain-section/8126/5 "2017-08-27T10:31:33Z")

</div>

It looks like you still not get what I mean and want me to keep hacking around.  
I can reorganize my templates without your help, thanks.

I have site logo and navigation in partial called `hat.html` that is inserted into base template.  
For navigation it’s usually important to know in what section I am at the moment. But I got use case where I also need to know where in pagination I am.  
Of course I can move some stuff from base into concrete templates, split `hat.html` into parts and make them inserted into concrete templates, passing my paginator where needed.

That’s what caused this topic, but not the point of this topic.
