How to setup Jekyll – static website generator on Ubuntu

Jekyll is a static site generator. You give it text written in your favorite markup language and it uses layouts to create a static website. You can tweak how you want the site URLs to look, what data gets displayed on the site, and more.

Following steps describes how you can install and setup jekyll on Ubuntu.

Dependency

  • Ruby version 2.4.0 or above, including all development headers (ruby version can be checked by running ruby -v)
  • RubyGems (which you can check by running gem -v)
  • GCC and Make (in case your system doesn’t have them installed, which you can check by running gcc -v,g++ -v and make -v in your system’s command line interface)
$ sudo apt install ruby
$ sudo apt install ruby-dev

Install Jekyll and bundler gems.

$ sudo gem install jekyll bundler
$ mkdir server
$ cd server/
$ sudo jekyll new myblog
$ cd myblog
$ sudo bundle exec jekyll serve

Above steps needs root permission, to avoid root permission

we need to change owner & group as,

$ cd ..
$ sudo chown -R myuser myblog/
$ sudo chgrp -R myuser myblog/
$ cd myblog/
$ bundle exec jekyll serve
Configuration file: /home/devlab/server/myblog/_config.yml
            Source: /home/devlab/server/myblog
       Destination: /home/devlab/server/myblog/_site
 Incremental build: disabled. Enable with --incremental
      Generating... 
       Jekyll Feed: Generating feed for posts
                    done in 0.326 seconds.
 Auto-regeneration: enabled for '/home/devlab/server/myblog'
    Server address: http://127.0.0.1:4000/
  Server running... press ctrl-c to stop.
[2020-04-04 10:13:28] ERROR `/favicon.ico' not found.
      Regenerating: 1 file(s) changed at 2020-04-04 10:16:25
                    _posts/static_dtc.txt
       Jekyll Feed: Generating feed for posts
                    ...done in 0.112965662 seconds.

As we can see above the newly created blog is started at http://127.0.0.1:4000/ or http://localhost:4000/

Reference – https://jekyllrb.com/docs/

Leave a Comment