Video summary (in bullet points) of Creating a Blog with Hugo and Github in 10 minutes by Ryan Schachte
Setup
- Create two repository:
- One for our Hugo code, your development repo, we will be calling this the dev repo
- Another for the deployed static rendered webpages, the production repo:
<name_of_the_site>.github.io, we will be calling this the prod repo
Hugo Stuff
- I will be installing Hugo in Windows 10, using chocolatey:
choco install hugo-extended clonethe dev repo andcdinto that- Create the hugo site there with
hugo new site <name_of_the_site>[0] cdinto the newly created<name_of_the_site>directory- Selecting a theme
- From your web browser, choose a theme from here: https://themes.gohugo.io/
- Follow the instructions to install the theme [1]
- Edit the
hugo.tomlfile:
baseURL = "https://anyfactor.github.io/"
languageCode = "en-us"
title = "Anyfactor's blog"
theme = "fuji"
I am using the fuji theme
- Development preview:
hugo server - Creating a new post:
hugo new posts/<name_of_post>.md - Edit the markdown blog post. Remove
draft: truefrom the metadata section. Add the tags and description metadata.
Deployment
- Adding the production site repo:
- Have atleast one commit on the prod repo for further future commits. You can clone the repo, run
touch README.mdand push the main branch. - On the dev repo add the prod repo as a submodule:
git submodule add -b main <prod_repo_url> public. [2] - The above command will bring the
mainbranch of the prod_repo to thepublicdirectory - The
publicdirectory will contain the rendedred static webpages. - When you render the static webpages the prod_repo contents will be written.
- Then you can push rendered static webpages to the web.
- Have atleast one commit on the prod repo for further future commits. You can clone the repo, run
- To generate the static files into the public directory:
hugo -t fuji.-tstands fortheme. cdinto thepublicdirectory where prod repo website lives. Gitadd→commit→pushto publish the new site.cdback into the previous (/root) directory. Gitadd→commit→pushthe dev repo.
Notes
[0] Create site first then add git
Create the site first, then inti the git repo there.
- Adding the theme:
git submodule add https://github.com/dsrkafuu/hugo-theme-fuji.git themes/fuji - Summary splitting. Add the summary section then add
<!--more-->then the main content : https://github.com/dsrkafuu/hugo-theme-fuji#-notice - Sample post metadata:
title: "Setting up Hugo"
date: 2023-07-01T23:06:13+06:00
description: "Creating a new hugo site using Ryan Schachte's tutorial"
tags: ['hugo']
[2]
mastervsmain
I need to declare the master branch here as my prod repo is older.