In this tutorial, you will learn how to create a portfolio website using Jekyll and GitHub Pages. Jekyll is a static site generator that allows you to build websites using Markdown, HTML, and CSS. GitHub Pages is a hosting service provided by GitHub that allows you to host static websites directly from a GitHub repository. By combining Jekyll and GitHub Pages, you can easily create and deploy a professional portfolio website.
Prerequisites
Before you begin, make sure you have the following prerequisites:
- Basic knowledge of HTML and CSS
- Git installed on your machine
- A GitHub account
Step 1: Install Jekyll
To get started, you need to install Jekyll on your local machine. Jekyll requires a few dependencies, including Ruby and RubyGems.
- Open your terminal or command prompt.
- Check if Ruby is installed by running the command
ruby -v
. If Ruby is not installed, you can download it from the official website (https://www.ruby-lang.org/en/downloads/). - Check if RubyGems is installed by running the command
gem -v
. If RubyGems is not installed, you can install it by following the instructions on the RubyGems website (https://rubygems.org/pages/download). - Install Jekyll by running the command
gem install jekyll
.
To verify that Jekyll is installed correctly, run the command jekyll -v
. It should display the version number of Jekyll.
Step 2: Create a New Jekyll Site
In this step, you will create a new Jekyll site using the command line.
- Create a new directory for your Jekyll site by running the command
mkdir my-portfolio
. - Navigate into the new directory by running the command
cd my-portfolio
. - Create a new Jekyll site by running the command
jekyll new .
. The dot at the end of the command specifies the current directory as the location for the new Jekyll site. - This will create a new Jekyll site with the default template and file structure.
Step 3: Customize the Jekyll Site
In this step, you will customize the default Jekyll site to create your portfolio website.
- Open the
_config.yml
file in a text editor. This file contains the configuration settings for your Jekyll site. - Update the
baseurl
andurl
settings with your GitHub Pages URL. For example:
baseurl: "/my-portfolio"
url: "https://your-username.github.io"
- Replace
your-username
with your GitHub username. - Update the
title
setting with the name of your portfolio website. - Update the
author
setting with your name or the name of your company. - Save and close the file.
Step 4: Create a Portfolio Layout
In this step, you will create a layout for your portfolio page.
- Create a new file called
portfolio.html
in the_layouts
directory. - Open the
portfolio.html
file in a text editor. - Add the following code to the file:
layout: default
title: Portfolio
<section class="portfolio">
<div class="grid">
{% for post in site.posts %}
<div class="item">
<a href="{{ post.url }}">
<img src="{{ post.image }}" alt="{{ post.title }}">
<h2>{{ post.title }}</h2>
<p>{{ post.description }}</p>
</a>
</div>
{% endfor %}
</div>
</section>
- Save and close the file.
Step 5: Create Your Portfolio Content
In this step, you will create the content for your portfolio page.
- Open the
_posts
directory. - Create a new file with the following naming convention:
YYYY-MM-DD-title.md
. ReplaceYYYY-MM-DD
with the current date andtitle
with a descriptive name for your portfolio item. - Open the new file in a text editor.
- Add the following front matter to the file:
title: Project 1
image: /path/to/image.jpg
description: This is a description of Project 1.
- Replace the
title
value with the title of your project. - Replace the
image
value with the path to an image for your project. - Replace the
description
value with a brief description of your project. - Save and close the file.
- Repeat steps 2-8 for each portfolio item you want to add.
Step 6: Customize the Styles
In this step, you will customize the styles of your portfolio website.
- Open the
assets/css/main.scss
file in a text editor. - Delete the existing styles and add your own styles.
- Customize the colors, fonts, and layout to match your desired design.
- Save and close the file.
Step 7: Test Locally
Before deploying your portfolio website to GitHub Pages, it’s a good idea to test it locally.
- Open your terminal or command prompt.
- Navigate to your Jekyll site directory.
- Run the command
jekyll serve
. This will start a local server and make your website accessible at `http://localhost:4000`. - Open your web browser and visit `http://localhost:4000` to view your portfolio website.
- Verify that everything looks and functions as expected.
Step 8: Deploy to GitHub Pages
Now that your portfolio website is ready, it’s time to deploy it to GitHub Pages.
- Create a new repository on GitHub with the name
your-username.github.io
, replacingyour-username
with your GitHub username. - Initialize a new Git repository in your Jekyll site directory by running the command
git init
. - Add the remote repository by running the command
git remote add origin https://github.com/your-username/your-username.github.io.git`, replacing
your-username` with your GitHub username. - Stage and commit your changes by running the following commands:
git add .
git commit -m "Initial commit"
- Push your changes to the
master
branch of your remote repository by running the commandgit push -u origin master
. - Wait for a few minutes and then visit `https://your-username.github.io` in your web browser to view your deployed portfolio website.
Step 9: Update Your Portfolio
To update your portfolio, follow these steps:
- Open your Jekyll site directory in your text editor.
- Make the necessary changes to your content, layouts, or styles.
- Commit and push your changes to your GitHub repository using the Git commands mentioned in Step 8.
- Visit `https://your-username.github.io` to view your updated portfolio website.
Congratulations! You have successfully created a portfolio website using Jekyll and deployed it to GitHub Pages. You can now showcase your projects and attract potential clients or employers with your professional portfolio.