Robert
Creating a website on GitHub is a great way to showcase your projects, write blogs, or even create a portfolio. GitHub Pages provides a free and easy way to host your static websites. In this tutorial, we will walk through the steps to build and deploy a website on GitHub.
Step 1: Create a GitHub Repository
- Log in to your GitHub account.
- Click the New repository button on your GitHub dashboard.
- Name your repository as
yourusername.github.io
. This is important as GitHub Pages will use this naming convention to recognize your repository as a website. - Add a short description, select Public, and initialize the repository with a
README.md
file. - Click Create repository.
Step 2: Install Git and Hexo
If you haven’t already, you’ll need to install Git and Hexo:
- Install Git: Download and install Git from git-scm.com.
- Install Node.js: Download and install Node.js from nodejs.org.
- Install Hexo: Open your terminal and run the following command:
1
npm install -g hexo-cli
Step 3: Set Up Your Hexo Site
- Open your terminal and navigate to the folder where you want to create your website.
- Run the following commands to set up your Hexo site:
1
2
3hexo init my-website
cd my-website
npm install
Step 4: Configure Your Site
Open the
_config.yml
file in the root of your Hexo project.Customize the basic settings like
title
,subtitle
,description
,author
, etc.1
2
3
4title: Robert's Website
subtitle: The most interesting website in the world
description: Welcome to the personal website of Robert, where you will find funny ideas and more.
author: Robert
Step 5: Choose a Theme
Browse for Hexo themes at Hexo Themes.
Once you find a theme you like, follow the installation instructions provided by the theme developer.
For example, to install the Next theme:
1
2cd themes
git clone https://github.com/next-theme/hexo-theme-next nextUpdate the
_config.yml
file to use the new theme:1
theme: next
Step 6: Write Your First Post
Create a new post with the following command:
1
hexo new post "My First Post"
Open the newly created file in the
source/_posts
directory and start writing your post in Markdown.
Step 7: Deploy Your Site
Open the
_config.yml
file and add the following lines for deployment:1
2
3
4deploy:
type: git
repo: https://github.com/yourusername/yourusername.github.io.git
branch: mainInstall the Hexo deployer plugin:
1
npm install hexo-deployer-git --save
Generate the static files and deploy your site:
1
2
3hexo clean
hexo generate
hexo deploy
Step 8: Access Your Website
Once the deployment is complete, you can access your website at https://yourusername.github.io
.
Congratulations! You have successfully built and deployed your website on GitHub. Continue to update your content, customize the theme, and make your website a reflection of your unique personality and interests.
Happy coding and welcome to the world of web development!