File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ # Sample workflow for building and deploying a Hugo site to GitHub Pages
2+ name : Deploy Hugo site to Pages
3+
4+ on :
5+ # Runs on pushes targeting the default branch
6+ push :
7+ branches : ["main"]
8+
9+ # Allows you to run this workflow manually from the Actions tab
10+ workflow_dispatch :
11+
12+ # Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
13+ permissions :
14+ contents : read
15+ pages : write
16+ id-token : write
17+
18+ # Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
19+ # However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
20+ concurrency :
21+ group : " pages"
22+ cancel-in-progress : false
23+
24+ # Default to bash
25+ defaults :
26+ run :
27+ shell : bash
28+
29+ jobs :
30+ # Build job
31+ build :
32+ runs-on : ubuntu-latest
33+ env :
34+ HUGO_VERSION : 0.147.7
35+ steps :
36+ - name : Checkout
37+ uses : actions/checkout@v4
38+ with :
39+ fetch-depth : 0 # fetch all history for .GitInfo and .Lastmod
40+ submodules : recursive
41+ - name : Setup Go
42+ uses : actions/setup-go@v5
43+ with :
44+ go-version : ' 1.22'
45+ - name : Setup Pages
46+ id : pages
47+ uses : actions/configure-pages@v4
48+ - name : Setup Hugo
49+ run : |
50+ wget -O ${{ runner.temp }}/hugo.deb https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_extended_${HUGO_VERSION}_linux-amd64.deb \
51+ && sudo dpkg -i ${{ runner.temp }}/hugo.deb
52+ - name : Build with Hugo
53+ env :
54+ # For maximum backward compatibility with Hugo modules
55+ HUGO_ENVIRONMENT : production
56+ HUGO_ENV : production
57+ run : |
58+ hugo \
59+ --gc --minify \
60+ --baseURL "https://${{ github.repository_owner }}.github.io/"
61+ - name : Upload artifact
62+ uses : actions/upload-pages-artifact@v3
63+ with :
64+ path : ./public
65+
66+ # Deployment job
67+ deploy :
68+ environment :
69+ name : github-pages
70+ url : ${{ steps.deployment.outputs.page_url }}
71+ runs-on : ubuntu-latest
72+ needs : build
73+ steps :
74+ - name : Deploy to GitHub Pages
75+ id : deployment
76+ uses : actions/deploy-pages@v4
Original file line number Diff line number Diff line change 1+ public /
Original file line number Diff line number Diff line change 1+ ---
2+ date : ' {{ .Date }}'
3+ draft : true
4+ title : ' {{ replace .File.ContentBaseName "-" " " | title }}'
5+ ---
Original file line number Diff line number Diff line change 1+ ---
2+ date : ' 2026-03-31T22:03:08+08:00'
3+ draft : true
4+ title : My Docs
5+ cascade :
6+ type : docs
7+ ---
Original file line number Diff line number Diff line change 1+ ---
2+ date : ' 2026-03-31T22:03:13+08:00'
3+ draft : true
4+ title : ' Blogs'
5+ cascade :
6+ type : blog
7+ ---
Original file line number Diff line number Diff line change 1+ ---
2+ date : ' 2026-03-31T22:03:13+08:00'
3+ draft : true
4+ title : ' Docs'
5+ ---
Original file line number Diff line number Diff line change 1+ ---
2+ date : ' 2026-03-31T22:04:48+08:00'
3+ draft : true
4+ linkTitle : Foo Bar
5+ title : ' Getting Start'
6+ ---
Original file line number Diff line number Diff line change 1+ baseURL : https://example.org/
2+ locale : zh-cn
3+ title : My New Hugo Project
4+ theme : hextra
You can’t perform that action at this time.
0 commit comments