How You Can Easily Build Your Own Site with Jekyll
Building your own website doesn’t have to be complicated or expensive. With Jekyll, you can create a beautiful, fast, and maintainable site that’s perfect for blogs, portfolios, or documentation. Let’s explore how you can get started with this powerful static site generator.
What is Jekyll?
Jekyll is a static site generator written in Ruby that transforms your plain text files into a complete website. It’s the engine behind GitHub Pages, which means you can host your site for free directly from your GitHub repository.
Why Choose Jekyll?
- Fast Performance: Static sites load incredibly quickly
- Free Hosting: Deploy to GitHub Pages at no cost
- Markdown Support: Write content in simple markdown format
- Customizable: Full control over design and functionality
- SEO Friendly: Clean URLs and optimized structure
Getting Started
Prerequisites
Before diving in, you’ll need:
- Basic knowledge of HTML/CSS
- Git installed on your computer
- A GitHub account
- Ruby installed (for local development)
Installation
# Install Jekyll
gem install jekyll bundler
# Create a new Jekyll site
jekyll new my-awesome-site
# Navigate to your site directory
cd my-awesome-site
# Start the local server
bundle exec jekyll serve
Your site will be available at http://localhost:4000!
Project Structure
A typical Jekyll site looks like this:
my-site/
├── _posts/ # Blog posts go here
├── _layouts/ # HTML templates
├── _includes/ # Reusable components
├── _sass/ # Sass stylesheets
├── assets/ # Images, CSS, JavaScript
├── _config.yml # Site configuration
└── index.md # Homepage content
Writing Your First Post
Create a new file in the _posts directory with the naming convention YYYY-MM-DD-title.md:
---
layout: post
title: "My First Jekyll Post"
date: 2025-08-30
categories: [blogging, jekyll]
---
Welcome to my Jekyll blog! This is my first post.
## Getting Started
Jekyll makes it easy to write in Markdown and have it
converted to beautiful HTML automatically.
### Features I Love
- Simple markdown syntax
- Automatic syntax highlighting
- Built-in pagination
- Theme support
Customizing Your Site
Configuration
Edit _config.yml to customize your site:
title: My Awesome Site
description: A blog about web development and life
author: Your Name
email: your-email@example.com
url: "https://yourusername.github.io"
# Build settings
markdown: kramdown
highlighter: rouge
permalink: /posts/:title/
# Plugins
plugins:
- jekyll-feed
- jekyll-sitemap
- jekyll-seo-tag
Layouts and Includes
Create reusable templates in _layouts and components in _includes:
<!-- _layouts/default.html -->
<!DOCTYPE html>
<html>
<head>
<title>{{ page.title }} - {{ site.title }}</title>
<meta name="description" content="{{ page.excerpt | strip_html }}">
</head>
<body>
{% include header.html %}
<main>
{{ content }}
</main>
{% include footer.html %}
</body>
</html>
Styling with Sass
Jekyll has built-in Sass support. Create a _sass directory and import your stylesheets:
// assets/css/main.scss
---
---
@import "base";
@import "layout";
@import "components";
Adding Features
Search Functionality
// assets/js/search.js
function performSearch() {
const query = document.getElementById('search-input').value.toLowerCase();
const posts = document.querySelectorAll('.post');
posts.forEach(post => {
const title = post.querySelector('h2').textContent.toLowerCase();
const content = post.querySelector('.excerpt').textContent.toLowerCase();
if (title.includes(query) || content.includes(query)) {
post.style.display = 'block';
} else {
post.style.display = 'none';
}
});
}
Contact Form
<!-- _includes/contact-form.html -->
<form action="https://formspree.io/f/your-form-id" method="POST">
<label for="name">Name:</label>
<input type="text" name="name" required>
<label for="email">Email:</label>
<input type="email" name="email" required>
<label for="message">Message:</label>
<textarea name="message" required></textarea>
<button type="submit">Send</button>
</form>
Deployment to GitHub Pages
- Create a GitHub repository named
username.github.io - Push your Jekyll site to the repository
- Enable GitHub Pages in repository settings
- Your site is live at
https://username.github.io
Custom Domain (Optional)
To use a custom domain:
- Add a
CNAMEfile to your repository root - Configure DNS settings with your domain provider
- Enable HTTPS in GitHub Pages settings
# CNAME file content
www.yourdomain.com
Performance Optimization
Image Optimization
<!-- Responsive images -->
<picture>
<source media="(max-width: 768px)" srcset="{{ '/assets/images/mobile-image.jpg' | relative_url }}">
<img src="{{ '/assets/images/desktop-image.jpg' | relative_url }}" alt="Description">
</picture>
Minification
Add to your _config.yml:
sass:
style: compressed
plugins:
- jekyll-minifier
Advanced Tips
Collections
Create custom content types beyond posts:
# _config.yml
collections:
projects:
output: true
permalink: /projects/:name/
Data Files
Store structured data in _data directory:
# _data/team.yml
- name: John Doe
role: Developer
image: john.jpg
- name: Jane Smith
role: Designer
image: jane.jpg
Liquid Templating
Use Jekyll’s templating language for dynamic content:
{% for post in site.posts limit:5 %}
<article>
<h2><a href="{{ post.url }}">{{ post.title }}</a></h2>
<time>{{ post.date | date: "%B %d, %Y" }}</time>
<p>{{ post.excerpt }}</p>
</article>
{% endfor %}
Common Pitfalls to Avoid
- Not testing locally before deploying
- Forgetting to update gems regularly
- Not optimizing images before uploading
- Ignoring SEO basics like meta tags and alt text
- Not backing up your content regularly
Useful Plugins
Extend Jekyll’s functionality with these popular plugins:
jekyll-sitemap- Generate XML sitemapjekyll-feed- Create RSS/Atom feedsjekyll-seo-tag- Add SEO meta tagsjekyll-paginate- Paginate blog postsjekyll-archives- Generate archive pages
Conclusion
Jekyll offers a perfect balance of simplicity and power for building modern websites. Whether you’re creating a personal blog, portfolio, or documentation site, Jekyll’s static site generation approach ensures fast performance and easy maintenance.
The best part? Once you understand the basics, you can focus on what matters most: creating great content. Your readers will thank you for the fast loading times, and you’ll appreciate the simple workflow.
Ready to start building? Head over to Jekyll’s official documentation and begin your journey into static site generation today!