This repository contains the raw content for my personal blog. The blog is generated using Hugo, a fast and flexible static site generator.
This guide will walk you through the steps of creating your Hugo-powered blog, linking it to a GitHub repository, applying a theme, and deploying it to GitHub Pages for free hosting.
The following section outlines how to generate the site and the corressponding
Create a new Hugo site using the following command:
hugo new site 'your-site-name' --format yaml
This will create a directory named 'your-site-name' with the following subdirectories:
- archetypes
- assets
- content
- data
- i18n
- layouts
- public
- static
- themes
- hugo.yaml
- Go to your GitHub account and click "New" to create a new repository.
- Name the repository (it can be the same as 'your-site-name').
- Choose between "Public" or "Private" visibility.
Initialize a Git repository in your Hugo site directory:
cd 'your-site-name'
git init
(Optional but recommended) Create a .gitignore file to exclude unnecessary files from your repository: The following site can be used to create generic .gitignore templates toptal.com
Add and commit the initial files:
git add .
git commit -m "initial commit"
Set the main branch as the default:
git branch -M main
Add the remote repository:
git remote add origin https://github.com/'your-github-username'/'your-repository-name'.git
Push the code to the repository:
git push -u origin main
- Browse the Hugo Themes website: themes.gohugo.io
- Choose a theme and copy its GitHub URL.
- Add the theme as a Git submodule:
git submodule add 'theme-github-url' themes/'theme-name'
Initialize and update the submodule
git submodule update --init --recursive
Follow the theme's documentation to configure it. Some themes may have an exampleSite directory that you can use as a starting point.
- If you don't have one, create a special repository named 'your-github-username'.github.io.
- Go to the repository settings and enable GitHub Pages. Your website URL will be: https://'your-github-username'.github.io
- In your Hugo site directory, delete the public folder if it exists.
- Add your GitHub Pages repository as a submodule in the public directory:
Next all you need to do is to delete the public folder in your blog and run the command below:
git submodule add https://github.com/'your-username'/'your-username'.github.io.git public
Build your site with the chosen theme:
hugo -t 'theme'
Commit and push the generated site to GitHub:
git add .
git commit -m "Initial Website Upload"
git push
And that's it.