Multiple blogs on jekyll and paginate_multiple

August 9, 2017

I’ve always wanted to have the ability to have separate blogs, by category, but since I don’t write were frequently, and certainly not enough to justify multiple distinct blogs, I gave up on the idea. When I started setting up this site, I realized that it would be easy to have multiple blogs, and still have them under the same system, and with a consistent theme across all of them, so it was too good to resist.

Setting up multiple blogs in a jekyll-powered site was super easy, but things seemed to get a bit complicated, when I tried to have pagination, using jekyll-paginate, on the other pages too. Now, on most jekyll sites, the landing page is the blog page, and the jekyll-paginate plugin handles the pagination of the index.html in the root directory. While jekyll allows one to have posts from different blogs in the same _posts directory, and have them kept apart using categories, jekyll-paginate doesn’t separate page contents by categories, thereby breaking pagination for all but the main page. Fortunately for me, there was jekyll-paginate-multiple.

jekyll-paginate-multiple however requires subdirectories to be setup under the _posts directory, for each category (where each category is actually a seperate blog), and each category should be a physical directory, with an index.html file.

I cannot have a bicycling.md or bicycling.html file serving a url such as http://pchengi.com/bicycling.

I cannot have a bicycling.md or bicycling.html file serving a url such as http://pchengi.com/bicycling. Instead, I have to have an index.html file, under the bicycling directory, under the root directory. Once I made these changes, and configured my _config.yml file with the appropriate values for jekyll-paginate-multiple, it was all great. My _config.yml file entries look like this:

paginate_multiple:
  - paginate: 5
    paginate_path: '/page:num/'
    sub_dir: '/general'
  - paginate: 5
    paginate_path: '/bicycling/page:num/'
    sub_dir: '/bicycling'
  - paginate: 5
    paginate_path: '/about/page:num/'
    sub_dir: '/about'

Now, I have three distinct blogs, all with pagination enabled. My main page would have technology related posts, while the Bicycling and the About pages would have my bicycling posts and personal posts respectively.