Prerequisites
This guide provides a step-by-step tutorial on how to install Jekyll, the popular static site generator, on your Linux system. We'll cover installing Ruby and RubyGems, setting up Jekyll, and verifying the installation.
Linux System: Ensure you have a Linux distribution (like Ubuntu, Debian, Fedora, etc.) installed.
Ruby and RubyGems: Jekyll requires Ruby and its package manager, RubyGems. Most Linux distributions have Ruby packages available. If not, you can install them using your distribution's package manager.
Install Ruby and RubyGems (if not already installed)
Using your distribution's package manager: This is the recommended method for most users.
Debian/Ubuntu:
sudo apt update
sudo apt install ruby ruby-dev build-essentialFedora:
sudo dnf install ruby ruby-devel gcc-c++ makeFrom source (advanced):
If you need a specific Ruby version or have particular requirements, you can install from source. This is generally not necessary for most users.
Install Jekyll using RubyGems
sudo gem install jekyll bundlerVerify Installation
Check the Jekyll version:
jekyll -vYou should see the installed Jekyll version.
Create a New Jekyll Site
Create a new directory for your Jekyll site:
mkdir my-jekyll-blog
cd my-jekyll-blogInitialize a new Jekyll site:
jekyll new .This will create a basic Jekyll site structure with necessary files and folders.
Run Jekyll Locally
Start the Jekyll server:
bundle exec jekyll servebundle exec: Ensures that your project's dependencies are used.
jekyll serve: Starts a local server that builds and serves your site.
Open your web browser and visit http://127.0.0.1:4000/ to see your newly created Jekyll site.
Basic Jekyll Site Structure
_config.yml: The main configuration file for your site._posts: Contains your blog posts (e.g., 2023-12-25-my-first-post.md)._layouts: Contains layout templates for different page types._includes: Contains reusable snippets of content._data: Contains site data in YAML format.index.html: The homepage of your site.Gemfile: Lists the Ruby gems required for your project.
Building Your Site
To build your site for deployment:
bundle exec jekyll buildThis will generate a static HTML, CSS, and JavaScript files in the _site directory.
That's it! You've successfully installed Jekyll on your Linux system and created a basic Jekyll site. You can now start customizing your site, adding content, and deploying it to a web server.
Additional Tips:
- Refer to the jekyllrb.comofficial Jekyll documentation for detailed information, advanced features, and troubleshooting
- Consider using a version control system like Git to track changes to your Jekyll site.
- Explore Jekyll plugins to extend its functionality.