Building, Deploying, and Hosting a Static Web Page with Jekyll
Building, Deploying, and Hosting a Static Web Page with Jekyll
In this guide, we’ll walk through the process of building, deploying, and hosting a static web page using Jekyll, a static site generator.
What is Jekyll?
Jekyll is a simple, blog-aware, static site generator built in Ruby. It allows you to create static websites from plain text files using templates. Jekyll is particularly popular for building personal blogs and portfolios.
Prerequisites
Before we begin, ensure you have the following installed:
- Ruby and RubyGems
- Bundler (a Ruby dependency manager)
Step 1: Installation
Install Jekyll using RubyGems:
1
gem install jekyll bundler
Step 2: Creating a New Jekyll Site
Create a new Jekyll site:
1
jekyll new my-site
Change into the newly created directory:
1
cd my-site
Step 3: Running the Development Server
Start the development server:
1
bundle exec jekyll serve
Access the site in your web browser at
http://localhost:4000
.
Step 4: Customizing Your Site
Edit the
_config.yml
file to customize settings such as site title, description, and theme.Modify the Markdown files in the
_posts
directory to add your content.Customize the layout and styling of your site by editing HTML and CSS files in the
_layouts
and_sass
directories.
Step 5: Building Your Site
Build your site for production:
1
bundle exec jekyll build
The generated static files will be placed in the
_site
directory.
Step 6: Deploying and Hosting Your Site
Choose a hosting provider for your static site. Options include GitHub Pages, Netlify, and AWS S3.
Follow the hosting provider’s instructions to deploy your site. Typically, this involves pushing your code to a Git repository and configuring your hosting provider to serve the static files from the
_site
directory.
Example: Deploying to GitHub Pages
Create a new Git repository on GitHub.
Push your Jekyll site to the repository:
1 2
git remote add origin https://github.com/username/repo-name.git git push -u origin master
Enable GitHub Pages for the repository in the repository settings.
Your site will be available at
https://username.github.io/repo-name
.
Congratulations! You’ve built, deployed, and hosted your own static web page using Jekyll.