Switch theme in an existing Jekyll installation

前端 未结 5 1449
栀梦
栀梦 2020-12-12 16:08

There are many themes for Jekyll, e.g. https://github.com/jekyll/jekyll/wiki/Themes.

What is the easiest way to switch to a new theme in an EXISTING Jekyll installat

5条回答
  •  不思量自难忘°
    2020-12-12 16:49

    Jekyll v3.2 introduced gem-based themes (for future plans see here):

    Gem-based themes make it easy for theme developers to make updates available to anyone who has the theme gem. When there’s an update, theme developers push the update to RubyGems

    The goal of gem-based themes is to allow you to get all the benefits of a robust, continually updated theme without having all the theme’s files getting in your way and over-complicating what might be your primary focus: creating content.

    Installing a gem-based theme is simple:

    1. Add the theme to your site’s Gemfile: gem "jekyll-theme-awesome"
    2. Install the theme: bundle install.
    3. Add the following to your site’s _config.yml to activate the theme: theme: jekyll-theme-awesome
    4. Build your site: bundle exec jekyll serve

    To switch themes, I believe something like this should work:

    1. Change to the new theme in your site’s Gemfile: gem "jekyll-theme-new"
    2. Install the theme: bundle install
    3. Change you site’s _config.yml to reference the new theme: theme: jekyll-theme-new
    4. Build your site: bundle exec jekyll serve
    5. (optional - uninstall the old theme from your machine) Note down the old theme's installation folder (bundle show jekyll-theme-awesome) and uninstall it with gem uninstall jekyll-theme-awesome. To be on the safe side, make sure its folder was indeed deleted.

    Updating gem-based themes is easy:

    If you have the theme gem, you can (if you desire) run bundle update to update all gems in your project. Or you can run bundle update , replacing with the theme name, such as minima, to just update the theme gem. Any new files or updates the theme developer has made (such as to stylesheets or includes) will be pulled into your project automatically.

    Important note: at the time of writing, GitHub pages only supports a specific set of gem-based themes: Architect, Cayman, Dinky, Hacker, Leap day, Merlot, Midnight, Minima, Minimal, Modernist, Slate, Tactile, and Time machine. Of those, it seems only Minima is blog-oriented (e.g. it's the only one with built-in Disqus support). However, you should be able to use any theme if you are willing to run the Jekyll build process yourself.

    Another alternative is GitLab pages (tutorial, sample site).

提交回复
热议问题