Replace homepage with an index from certain section?

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:

{{ $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

homeSection = "post"

As the result, index page will have permalink 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 -

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.

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

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.

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 is my homepage and redirect from homepage to there, but that’s ugly. I don’t want to have links of a form anywhere. 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.

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).

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. :slight_smile:

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.