Jekyll on Fedora - Installation and use
Jekyll is a generator of static sites, with blog recognition, for personal sites, projects or organizations, with support for GitHub.
- Installing Jekyll
- Host a website on GitHub
- Clone a GitHub Pages site locally
- Uninstalling Jekyll
Installing Jekyll
These instructions apply to Fedora 41 KDE Plasma.
~$ sudo dnf group install development-tools
~$ sudo dnf install ruby ruby-devel openssl-devel redhat-rpm-config gcc-c++
Avoid installing RubyGems packages (called gems) as the root user. Instead, set up a gem installation directory in your user account.
The following commands add environment variables to your ~/. bashrc to configure the gem installation path. Run the commands with your user:
~$ echo '# Install Ruby Gems to ~/gems' >> ~/.bashrc
~$ echo 'export GEM_HOME="$HOME/gems"' >> ~/.bashrc
~$ echo 'export PATH="$HOME/gems/bin:$PATH"' >> ~/.bashrc
~$ source ~/.bashrc
Finally install Jekyll.
~$ gem install jekyll bundler
Create a folder with the name, for example, “mysite”, for the Jekyll website. Enter the folder and build the website.
~$ jekyll new mysite
~$ cd mysite
~/mysite$ bundle exec jekyll serve --livereload
Open your browser at http://localhost:4000
The theme installed by default: minima
Host a website on GitHub
Create a new public repository on GitHub, in the format username.github.io, where username is your username.
Install the GitHub CLI (gh) and run it to automatically store your credentials on GitHub. You can then choose HTTPS as your preferred protocol for Git operations, and answer "yes" to the prompt that will ask if you would like to authenticate to Git with your GitHub credentials.
~$ sudo dnf install gh
~$ gh auth login
Select the following answers to the following questions:
Where do you use GitHub? GitHub.com
What is your preferred protocol for Git operations on this host? HTTPS
Authenticate Git with your GitHub credentials? Yes
How would you like to authenticate GitHub CLI? Login with a web browser
! First copy your one-time code: XXXX-XXXX (It is a code with letters and numbers that will be used in the browser in the next step, right after authenticating.)
Press Enter to open https://github.com/login/device in your browser...
✓ Authentication complete.
Initialize the Git repository and sync the site.
~/mysite$ git init
~/mysite$ git checkout -b master
~/mysite$ git status
~/mysite$ git add .
~/mysite$ git config --global user.email "me@example.com"
~/mysite$ git config --global user.name "My name"
~/mysite$ git commit -m "Commit inicial"
~/mysite$ git remote add origin https://github.com/username/username.github.io.git
~/mysite$ git push -u origin master
Clone a GitHub Pages site locally
After creating the site on GitHub, we can clone the site locally. To do this, go to the folder where you want to store the project and clone the new repository. In this example I will do the cloning inside the “mysite” folder. Cloning will automatically create a folder named username.github.io
~/mysite$ git clone https://github.com/username/username.github.io
After you create or change a file, for example index.html, push the new file or new version to GitHub.
~/mysite$ cd username.github.io
~/mysite/username.github.io$ git add index.html (if it is a new file)
~/mysite/username.github.io$ git commit index.html -m “Initial commit”
~/mysite/username.github.io$ git push origin master
And we have the website at https://username.github.io
If you come across "error: pathspect 'commit' did not match any file(s) known to git", write the command manually in Terminal instead of copying/pasting from the website.
Uninstalling Jekyll
~$ gem uninstall jekyll