This tutorial intends to teach you to Install and Configure Jekyll static site generator on AlmaLinux 8.
Jekyll is a free and open-source static site generator. Like a content management system (for example, Drupal and WordPress), Jekyll can be used to build websites with rich and easy-to-use navigation. Unlike Drupal and WordPress, however, Jekyll generates all the content at once, instead of waiting for people to visit your website’s pages.
Steps To Install and Configure Jekyll on AlmaLinux 8
To complete this guide, you must log in to your server as a non-root user with sudo privileges and set up a basic firewall. To do this, you can follow our guide on Initial Server Setup with AlmaLinux 8.
Now follow the steps below to complete your Jekyll installation.
Install Ruby on AlmaLinux 8
Jekyll is written in Ruby, so you need to have Ruby installed on your AlmaLinux server.
First, update your local package index with the command below:
sudo dnf update -y
Then, use the commands below to install dependencies and required packages:
# sudo dnf install git make gcc curl openssl-devel zlib-devel libffi-devel readline-devel sqlite-devel -y
# sudo dnf group install "Development Tools" -y
Now use the command below to install Ruby on your server:
# sudo dnf module reset ruby -y
# sudo dnf install @ruby:3.1 -y
Verify your Ruby installation by checking its version:
ruby 3.1.2p20 (2022-04-12 revision 4491bb740a) [x86_64-linux]
Install the ruby-devel package by using the command below:
sudo dnf install ruby-devel -y
Set up Jekyll on AlmaLinux 8
At this point, you need to configure the Ruby Gems path and then install Jekyll on your AlmaLinux server.
Configure Ruby Gems Path
Here you need to open your bashrc file with your favorite text editor, here we use the vi editor:
Then, add the following content to the file:
# Install Ruby Gems to ~/.gems
When you are done, save and close the file.
Source the profile by running the command below:
Install Jekyll Site Generator on AlmaLinux 8
At this point, you can easily use the following gem command to install the Jekyll Website generator:
gem install jekyll bundler
Successfully installed bundler-2.4.10
Parsing documentation for bundler-2.4.10
Installing ri documentation for bundler-2.4.10
Done installing documentation for bundler after 0 seconds
31 gems installed
To update Ruby gems on AlmaLinux 8, run the command below:
gem update --system
Create a Demo Site with Jekyll
At this point, we will show you how to create a new demo site by using Jekyll on AlmaLinux 8.
To do this, switch to your home directory and run the following command to create the demo site:
# cd ~
# jekyll new demo-site
You can check the files inside your demo site directory by using the command below:
# sudo dnf install tree -y
# tree demo-site
1 directory, 7 files
Run Web Server with Jekyll
Now Jekyll can monitor the files in the created directory and quickly generate a static site from them on AlmaLinux 8. It also automatically regenerates the site when changes are made to these files.
To run the web server, use the following commands:
# cd ~/demo-site
# bundle add webrick
# jekyll serve --host=your-host-ip-address
Note: With no host specified, Jekyll will serve the site on localhost.
Auto-regeneration: enabled for '/root/demo-site'
Server address: http://ip-address:4000/
Server running... press ctrl-c to stop.
When the above command is executed, Jekyll with use configurations and content in the directory
│ └── 2023-04-04-welcome-to-jekyll.markdown
│ └── index.html
│ ├── main.css
│ ├── main.css.map
│ └── minima-social-icons.svg
9 directories, 15 files
You can also run the Jekyll server in the background:
jekyll serve --host=host-ip > /dev/null 2>&1 &
Access Jekyll Site on AlmaLinux 8
At this point, you can access the site by typing the following URL in your web browser:
You will see the Jekyll Welcome page.
Now we want to show you how to add a post on your Jekyll site on AlmaLinux 8.
Create a Sample Post on Jekyll
Posts are added to the
_posts directory with the following format:
- YEAR is a four-digit number, and MONTH and DAY are both two-digit numbers example; 2023-01-07
- MARKUP is the file extension representing the format used in the file.
For example, use the command below to create a hello world post:
Add the below lines to the file.
title: "Hello World!"
**Hello world**, this is my first Jekyll blog post.
I hope you like it!@OrcaCoreTeam
When you are done, save and close the file.
Finally, refresh your Jelly Site page, and you will see:
You can click on your post to see the content of the post you have added:
At this point, you have learned to Install and Configure Jekyll static site generator on AlmaLinux 8.
Hope you enjoy it. You may be like these articles on the Orcacore website: