This guide walks through creating a GitHub Pages website powered by Jekyll and running it locally so changes can be previewed before publishing.
- Go to GitHub → New Repository
- Name it:
username.github.io
- Set it to Public
- Click Create Repository
Jekyll is Ruby-based. You need:
- Ruby
- Bundler
- Jekyll
- GitHub Pages gem (recommended for compatibility)
Open a terminal and run:
jekyll new username
cd usernameFind a Jekyll theme repository (https://github.com/pages-themes/) and follow the directions, specifically about modifying the _config.yml in your repository.
Edit _config.yml.
url: "https://username.github.io"
baseurl: ""This ensures links and assets resolve properly.
Initialize Git
git init
git add .
git commit -m "Initial Jekyll site"Add Remote and Push
git branch -M main
git remote add origin git@github.com:<username>.<username>.github.io.git
git push -u origin mainIn your GitHub repository:
- Go to Settings
- Click Pages
- Under Build and deployment
- Source: Deploy from a branch
- Branch:
main - Folder:
/(root)
GitHub will display the published site URL once deployed!
GitHub Pages runs specific gem versions. To match them locally:
In file named Gemfile replace the contents with:
source "https://rubygems.org"
gem "github-pages", group: :jekyll_pluginsIn your terminal:
bundle installStart the local server:
bundle exec jekyll serveThen open:
http://127.0.0.1:4000Common files and folders:
_config.yml # Site configuration
_layouts/ # Page templates
_includes/ # Reusable components
_posts/ # Blog posts
assets/ # CSS, images, JS
index.md # Homepage
Auto rebuild + live reload:
bundle exec jekyll serve --livereloadServe drafts:
bundle exec jekyll serve --draftsStop server with:
Ctrl + C