Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save morisono/e8c0766d06808db0ddf7fa08828dd2d8 to your computer and use it in GitHub Desktop.
Save morisono/e8c0766d06808db0ddf7fa08828dd2d8 to your computer and use it in GitHub Desktop.

How to start Hugo site

Clone Template and Setup Git

❯ git clone https://github.com/adityatelange/hugo-PaperMod mysite --depth=1
Cloning into 'mysite'...
remote: Enumerating objects: 139, done.
remote: Counting objects: 100% (139/139), done.
remote: Compressing objects: 100% (100/100), done.
remote: Total 139 (delta 38), reused 126 (delta 34), pack-reused 0 (from 0)
Receiving objects: 100% (139/139), 249.22 KiB | 153.00 KiB/s, done.
Resolving deltas: 100% (38/38), done.

❯ git init
Reinitialized existing Git repository in../mysite/.git/

❯ git remote add origin "https://oauth2:$PAT@github.com/<username>/papermod-demo"
fatal: not a git repository (or any parent up to mount point /mnt)
Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).

❯ git init
Initialized empty Git repository in ../mysite/.git/

❯ git remote add origin "https://oauth2:$PAT@github.com/<username>/papermod-demo"

❯ git add .

❯ git commit -m 'first commit'

Then create repo at website. Named papermod-demo

❯ git push origin main

If you miss type PAT, retry as below:

set PAT ghp_*****************************

❯ git remote set-url origin "https://oauth2:$PAT@github.com/<username>/papermod-demo"

❯ git push origin main

Build

❯ sed -i 's/adityatelange/<username>/g' theme.toml

❯ sed -i 's/hugo-PaperMod/<reponame>/g' theme.toml

❯ hugo

Deploy

❯ git add -A

❯ git commit -m 'builded'
git [main 8a35a5b] builded
p 12 files changed, 834 insertions(+), 3 deletions(-)
 create mode 100644 .hugo_build.lock
 create mode 100644 public/404.html
 create mode 100644 public/assets/css/stylesheet.fc220c15db4aef0318bbf30adc45d33d4d7c88deff3238b23eb255afdc472ca6.css
 create mode 100644 public/categories/index.html
 create mode 100644 public/categories/index.xml
 create mode 100644 public/index.html
 create mode 100644 public/index.xml
 create mode 100644 public/page/1/index.html
 create mode 100644 public/sitemap.xml
 create mode 100644 public/tags/index.html
 create mode 100644 public/tags/index.xml

❯ git push origin main
Enumerating objects: 23, done.
Counting objects: 100% (23/23), done.
Delta compression using up to 2 threads
Compressing objects: 100% (17/17), done.
Writing objects: 100% (21/21), 8.86 KiB | 76.00 KiB/s, done.
Total 21 (delta 7), reused 0 (delta 0), pack-reused 0 (from 0)
remote: Resolving deltas: 100% (7/7), completed with 2 local objects.
To https://github.com/username/papermod-demo
   36f1a80..8a35a5b  main -> main

Publish

First you must public your repository, at GitHub settings page:

Change:
  - Source: Github Actions
  - Branch: `/docs`

Next, you should append github-actions-workflow, then save as .github/workflow/hugo.yaml,

# Step 6 from https://gohugo.io/hosting-and-deployment/hosting-on-github
mkdir -p .github/workflow/
pbpaste > .github/workflows/hugo.yaml

git add -A
git commit -m 'add workflow deploy'
git push origin main

Now you can access your website: https://username.github.io/papermod-demo !

Post

So let's post your first article

Add markdown doc in /contents/*

mkdir contents
code contents/getting-started-hugo-site.md

Article like below:

---
title: "Archive"
layout: "archives"
url: "/archives/"
summary: archives
---

# Getting started Hugo website!
...


Then build and deploy:
```bash
hugo build

git add -A
git commit -m 'first post'
git push origin main

Customize website

For more information about customization the theme, see here and here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment