Jekyll is a versatile and user-friendly static website generator that allows you to create stunning websites with ease. Whether you’re a seasoned developer or an aspiring blogger, Jekyll provides a simple and efficient way to build and maintain your website. In this article, we will guide you through the process of installing Jekyll on Ubuntu 22.04, enabling you to harness the power of this powerful tool.
Before we dive into the installation process, there are a few prerequisites that need to be met:
- A server running Ubuntu 22.04.
- A root password is configured on your server.
If you have these prerequisites in place, you’re ready to proceed with the installation.
To ensure that your system is up to date, it is recommended to update it with the latest stable version. Open the terminal and run the following commands:
apt update -y apt upgrade -y
Once your system is up-to-date, you need to install some dependencies that are required for Jekyll. Run the following command to install the necessary packages:
apt install make build-essential curl git tree -y
With all the dependencies installed, we can now move on to installing Ruby, the programming language that Jekyll is built on.
Jekyll is written in Ruby, so you will need to install it on your system. By default, the Ruby package is included in the Ubuntu default repository. You can install Ruby by running the following command:
apt install ruby ruby-dev -y
Once the installation is complete, we need to configure Ruby’s gem package manager to place gems in our user’s home folder. Open the
~/.bashrc file using your preferred text editor:
Add the following lines at the end of the file:
export GEM_HOME=$HOME/gems export PATH=$HOME/gems/bin:$PATH
Save and close the file. Activate the environment variable with the following command:
Now, we can install Jekyll and Bundler using the gem command:
gem install jekyll bundler
With Jekyll and Bundler successfully installed, we can move on to creating a new website using Jekyll.
Create a New Website with Jekyll
To create a new website with Jekyll, run the following command:
jekyll.example.com with the desired name for your website. Once the command completes, you will see a list of files and directories created by Jekyll.
This command will output a directory structure like this:
jekyll.example.com ├──404.html ├── about.markdown ├── _config.yml ├── Gemfile ├── Gemfile.lock ├── index.markdown └── _posts └──2022-09-25-welcome-to-jekyll.markdown
Your Jekyll website is now ready to be served.
Start Jekyll Server
To view your Jekyll website locally, you need to start the Jekyll web server. Navigate to the website directory using the following command:
Next, add the
webrick dependency by running the following command:
bundle add webrick
Finally, start the Jekyll web server by running the following command:
jekyll serve --host=0.0.0.0
Once the server starts successfully, you will see the following output:
Configuration file: /root/jekyll.example.com/_config.yml Source: /root/jekyll.example.com Destination: /root/jekyll.example.com/_site Incremental build: disabled. Enable with --incremental Generating... Jekyll Feed: Generating feed for posts done in 0.375 seconds. Auto-regeneration: enabled for '/root/jekyll.example.com' Server address: http://0.0.0.0:4000/ Server running... press ctrl-c to stop.
Access the Jekyll Website
With the Jekyll server up and running, you can now access your website by opening your web browser and entering the URL
http://your-server-ip:4000. You will be redirected to the Jekyll default page, where you can explore the possibilities of this powerful tool.
Congratulations! You have successfully installed Jekyll on Ubuntu 22.04 and created your first Jekyll website. With Jekyll, you have the power to create and customize static websites with ease. Whether you’re a developer or a blogger, Jekyll provides a simple yet powerful platform to showcase your content. Start exploring the features and unleash your creativity with Jekyll today!
For more information about cloud hosting solutions and how Shape.host can empower your business with efficient, scalable, and secure hosting services, visit Shape.host.