Implement pagination not in index file

Hey there,

I’m still learning the Jekyll environment and yet facing an issue on how to implement pagination in a website. Although it seems to be an easy issue, I don’t think it is (at least for me haha).

We want to implement pagination only in the blog, we use three builds of Jekyll to generate our website, one for the root website ‘domain/’, one for documentation ‘domanin.com/doc’ and finally, one for ‘/blog/’.

I configured the config.yml file as this:

    paginate: 6
    paginate_path: "/blog/:num/"

We didn’t have a index file in the root of the project, so it was throwing an error:
Pagination: Pagination is enabled, but I couldn’t find an index.html page to use as the pagination template. Skipping pagination.

This happened because we had the blog page being generated in the folder /pages/blog/index.html.

The way we fixed was to create the index.html file (of course) in the root of the directory, but it generates the first page of the blog as ‘domain/index.html’ and if we deploy as this, it will create a conflict with the main website, that are using that adress. The pagination are being generated correctly, /blog/2 and so on.

What I though as a possible solution was to set a permalink in the frontmatter of the index file as ‘/blog’, but it doesn’t work.

The question is: is there a way to generate the first page of the blog inside the /blog folder and not in the root?

Try /blog/.

Is your homepage site and your blog in different repos?

Because then you can have your blog repo with content at the root of the repo and set up the site to build to a subpath.

baseurl: /blog/

And then paginate could point at the root.

I suggest that, because GitHub Pages let’s you deploy Jekyll sites on the same domain by setting baseurl as above. Then the index.md page of my my-site becomes /my-site/index.html.

You can also consider merging your blog and homepage as one repo. Also note that Jekyll sites don’t usually have a folder called blog. The posts go in _posts and get output as /2021/01/02/title.html.

Hey Michael,

We are using three different repos. One thing i forgot to mention is that we use multi language website, so if I set a baseurl as ‘/blog’, it will break all urls:

With baseurl as ‘/blog’ it generates pages like this:
domain-com/blog/language/page2

But all our websites have the language as the root directory:

domain-com/pt-br
domain-com/es
domain-com/en-us