Creating a Blog with Jekyll and Publishing on GitHub Pages
What is Jekyll?
Jekyll is a popular static site generator used for creating blogs and static websites. Jekyll allows you to write your content in Markdown or HTML and then converts these into static HTML files. This makes your site fast and secure since it doesn’t need to pull data dynamically from a database.
Advantages of Jekyll
Simple Setup: Easily installed with Ruby. Markdown Support: Writing content in Markdown makes formatting easy. Themes and Plugins: Extensive support for themes and plugins allows you to personalize your site. GitHub Pages Integration: Works seamlessly with GitHub Pages for easy publishing.
How to Create a Blog Site with Jekyll
1. Install Jekyll and Necessary Tools
First, we need to install Jekyll and Bundler. Open your terminal and run the following commands:
gem install jekyll bundler
2. Create a New Jekyll Site
To create a new Jekyll site, use the command:
jekyll new my-awesome-blog
cd my-awesome-blog
3. Run the Site Locally
To run the site locally:
bundle exec jekyll serve
You can now view your site in your browser at http://localhost:4000.
4. Adding Content
Create a New Post
Navigate to the _posts directory and create a new Markdown file. The filename should follow this format: YYYY-MM-DD-title.md.
For example: 2024-06-20-my-first-post.md
The content of the file could be:
---
layout: post
title: "My First Post"
date: 2024-06-20 10:00:00 +0000
categories: jekyll update
---
Writing my first post with Jekyll!
5. Publishing on GitHub Pages
Create a GitHub Repository
Create a new repository on GitHub. Name the repository username.github.io.
Push Your Project to GitHub
In your terminal, follow these steps:
---
git init
git add .
git commit -m "Initial blog setup"
git branch -M main
git remote add origin https://github.com/username/username.github.io.git
git push -u origin main
Configure GitHub Pages
Go to your repository settings on GitHub and click on the “Pages” section. Select the “main” branch as the source and save.
Within a few minutes, your site will be live at https://username.github.io.
Conclusion
Jekyll is an excellent tool for creating blogs and static websites. With a simple setup process, Markdown support, and GitHub Pages integration, you can quickly create and publish your own blog site. If you want to further customize your site, don’t forget to explore Jekyll’s wide range of themes and plugins!