This repository contains the code of my personal blog, built using hugo-PaperMod and Github Pages.
Check out my website at nidhihemanth.github.io๐
Visit here for detailed instructions.
Clone the project on your local machine.
For example, using https git clone https://github.com/nidhihemanth/nidhihemanth.github.io.git
Open the command line in the cloned directory.
Run hugo server
which will run the application locally on the default port http://localhost:1313/
Now you can view & test your changes locally before deploying it ๐
Hugo is a fast and modern static site generator written in Go, and designed to make website creation fun again.
Hugo provides us a wide variety of themes which makes it easier to create & maintain simple websites. The theme used in this repository is called PaperMod.
We assume all the prerequisites have already been installed.
- Create a new site using the command
hugo new site <name of site> --format yaml
in your command line. - Change current directory to project directory using
cd <name of site>
. This creates the directory structure of our project. - Add the desired theme to your project by executing the following commands
git clone https://github.com/adityatelange/hugo-PaperMod themes/PaperMod --depth=1 cd themes/PaperMod git pull
- From the root directory execute the following command to add the theme as a submodule to your repository.
Replace the links in step 3 & 4 to the github repository of your desired theme.
git submodule add --depth=1 https://github.com/adityatelange/hugo-PaperMod.git themes/PaperMod
- Update the theme in your hugo.yaml file by setting the theme as
theme: "PaperMod"
- Initialise the project as git repository executing
git init
from the root directory of the hugo site. - Create a new repository on Github and name it as
<username>.github.io
. This will be the URL of your GitHub Pages website. - In the
hugo.yoml
file update baseURL to point to your github pagebaseURL: "https://<username>.github.io"
- Push the hugo site to the empty Github repository
git remote add origin https://github.com/<username>/<username>.github.io.git git branch -M main git commit -m "first commit" git push -u origin main
Additionally, create new pages using hugo new <filename>
on your website, refer to your respective theme documentations for detailed instructions.
- Manually create a new branch in the Github repository named
gh-pages
. This is the branch github pages will fetch from. - Allow Read and Write Permissions on the Workflow under Settings > Actions > General > Workflow permissions
- Set the GitHub Pages site to build from the
gh-pages
branch under Settings > Pages > Build and deployment - Define custom github actions to fetch code from the main branch and create a static site in the
gh-pages
branch.- For that add the following file under with the same directory structure .github/workflows/deploy.yml under your project root directory.
- (You might want to change the version of hugo being downloaded to the latest version in the
curl
command under "Setup Hugo")
Github automatically deploys the code at https://<username>.github.io
To deploy your website under a custom Domain Name refer to this article.