Post

Jekyll Build on Windows

Instructions1

Installing Ruby and Jekyll

The easiest way to install Ruby and Jekyll is by using the RubyInstaller for Windows. RubyInstaller is a self-contained Windows-based installer that includes the Ruby language, an execution environment, important documentation, and more.

  1. Download and install a latest Ruby+Devkit version from RubyInstaller Downloads. Use default options for installation.

    WHICH VERSION TO DOWNLOAD?

    If you don’t know what version to install and you’re getting started with Ruby, we recommend that you use the Ruby+Devkit 3.2.X (x64) installer. It provides the biggest number of compatible gems and installs the MSYS2 Devkit alongside Ruby, so gems with C-extensions can be compiled immediately. The 32 bit (x86) version is not recommended, unless custom 32 bit native DLLs or COM objects have to be used.

    HOW TO UPDATE?

    Ruby can be updated to the latest patch version (e.g. from 3.1.0 to 3.1.3) by running the new installer version. Installed gems are not overwritten and will work with the new version without re-installation. It’s sufficient to use the RubyInstaller without Devkit for these update installations. The Devkit can be updated separately using the ridk install command.

    If the new Ruby version is from a different stable branch, then please use a new target directory for installation. That is to say, a previous RubyInstaller-3.1.x installation should not be updated by installing RubyInstaller-3.2.x into the same directory. This is because gems with C extensions are not compatible between ruby-3.1 and 3.2. Find out more in the FAQ.

  2. Run the ridk install step on the last stage of the installation wizard. This is needed for installing gems with native extensions. From the options input number 3 to choose MSYS2 and MINGW development tool chain.

  3. Open a new Start Command Prompt with Ruby from the start menu, so that changes to the PATH environment variable becomes effective. Install Jekyll and Bundler using:

    1
    
    gem install jekyll bundler
    
  4. Check if Jekyll has been installed properly:

    1
    
    jekyll -v
    

    You may receive an error when checking if Jekyll has not been installed properly. Reboot your system and run jekyll -v again. If the error persists, please open a RubyInstaller issue.

That’s it, you’re ready to use Jekyll!


Build & run local Jekyll site2

  1. Create a new Jekyll site at ./myblog.

    1
    
    jekyll new myblog
    
  2. Create the “myblog” folder in the, for example, D:\Jekyll\myblog directory.

    1
    
    mkdir D:\Jekyll\myblog
    
  3. Change into your new directory.

    1
    
    cd /d D:\Jekyll\myblog
    
  4. Build the site and make it available on a local server.

    1
    
    bundle exec jekyll serve
    
  5. Browse to http://localhost:4000

    If you are using Ruby version 3.0.0 or higher, step 5 may fail. You may fix it by adding webrick to your dependencies: bundle add webrick

    Pass the --livereload option to serve to automatically refresh the page with each change you make to the source files: bundle exec jekyll serve --livereload

    If you encounter any errors during this process, check that you have installed all the prerequisites in Requirements. If you still have issues, see Troubleshooting.


Use alternative Jekyll theme3

Prerequisites

Follow the instructions in the Jekyll Docs to complete the installation of the basic environment. Git also needs to be installed.

Installation

Sign in to GitHub and use chirpy template to generate a brand new repository and name it USERNAME.github.io, where USERNAME represents your GitHub username.

Replace the bundler default source with running the following command4 to fix network download issue when bundle.

1
bundle config mirror.https://rubygems.org https://mirrors.tuna.tsinghua.edu.cn/rubygems

Then clone it to your local machine and run:

1
bundle

Tutorial Wiki5

  • Jekyll-Compose plugin

Add this line to your application’s Gemfile:

1
gem 'jekyll-compose', group: [:jekyll_plugins]

And then execute:

1
bundle

Create your new post using:

1
bundle exec jekyll compose "My New Post" --post

References

This post is licensed under CC BY 4.0 by the author.

Comments powered by Disqus.