rubyjekyllgithub-pagestravis-cijekyll-theme

Why does jekyll-archives not work on Github pages with Travis CI?


I am using Travis to deploy on Github pages. I am also using jekyll-archives in my project. My setup works very well locally but no archive pages are generated on github pages. I have also used jekyll-paginate-v2 which is also not whitelisted on github pages and it works perfectly with Travis deployment. I cannot figure out jekyll-archives issue.

My Gemfile

source 'https://rubygems.org'
gem 'jekyll', '<4'
gem 'html-proofer', '4.3.1'
gem 'jekyll-archives'
gem 'jekyll-sitemap'
gem 'jekyll-paginate-v2'
gem 'kramdown-parser-gfm'
gem 'webrick'

My _config.yml

plugins:
  - jekyll-archives
  - jekyll-sitemap
  - jekyll-paginate-v2

exclude:
  - "/vendor/"

future: true
timezone: Asia/Kolkata

# Build settings
markdown: kramdown
inter_post_navigation: true
highlightjs_theme: "monokai-sublime"

# Pagination Settings
pagination:
  enabled: true
  per_page: 5
  permalink: "/page/:num/"
  sort_reverse: true

# Archive settings
jekyll-archives:
  enabled:
    - categories
    - tags
  layout: archive
  permalinks:
    category: '/category/:name/'
    tag: '/tag/:name/'

My .travis.yml

language: ruby
rvm:
  - 2.6.3
cache: bundler
install:
  - gem install bundler
  - gem update --system 3.2.3
  - bundle install
script:
  - bundle exec jekyll build
branches:
  only:
    - master
addons:
  apt:
    packages:
      - libcurl4-openssl-dev
deploy:
  provider: pages
  skip_cleanup: true
  local_dir: _site
  github_token: $TRAVIS_DEPLOY_TOKEN
  keep_history: true
  on:
    branch: master
  repo: <org>/<repo>.github.io
  target_branch: gh-pages
notifications:
  email: false

Solution

  • As it turns out, jekyll-archives was working correctly but creating slugified links per its default settings. On the other hand, I kept category links as it is in the anchor tag in html files. So I had to place slugify filter in the anchor tag.

    Before

    <a href="{{ site.baseurl }}/category/{{ cat }}">{{ cat | capitalize }}</a>
    

    After

    <a href="{{ site.baseurl }}/category/{{ cat | slugify }}">{{ cat | capitalize }}</a>