Skip to content

Commit 654e308

Browse files
authored
Initial commit
0 parents  commit 654e308

File tree

35 files changed

+827
-0
lines changed

35 files changed

+827
-0
lines changed

.devcontainer/Dockerfile

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Update the NODE_VERSION arg in docker-compose.yml to pick a Node version: 18, 16, 14
2+
ARG NODE_VERSION=16
3+
FROM mcr.microsoft.com/devcontainers/javascript-node:${NODE_VERSION}
4+
5+
# VARIANT can be either 'hugo' for the standard version or 'hugo_extended' for the extended version.
6+
ARG VARIANT=hugo
7+
# VERSION can be either 'latest' or a specific version number
8+
ARG VERSION=latest
9+
10+
# Download Hugo
11+
RUN apt-get update && apt-get install -y ca-certificates openssl git curl && \
12+
rm -rf /var/lib/apt/lists/* && \
13+
case ${VERSION} in \
14+
latest) \
15+
export VERSION=$(curl -s https://api.github.com/repos/gohugoio/hugo/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4)}') ;;\
16+
esac && \
17+
echo ${VERSION} && \
18+
case $(uname -m) in \
19+
aarch64) \
20+
export ARCH=ARM64 ;; \
21+
*) \
22+
export ARCH=64bit ;; \
23+
esac && \
24+
echo ${ARCH} && \
25+
wget -O ${VERSION}.tar.gz https://github.com/gohugoio/hugo/releases/download/v${VERSION}/${VARIANT}_${VERSION}_Linux-${ARCH}.tar.gz && \
26+
tar xf ${VERSION}.tar.gz && \
27+
mv hugo /usr/bin/hugo
28+
29+
# Hugo dev server port
30+
EXPOSE 1313
31+
32+
# [Optional] Uncomment this section to install additional OS packages you may want.
33+
#
34+
# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
35+
# && apt-get -y install --no-install-recommends <your-package-list-here>
36+
37+
# [Optional] Uncomment if you want to install more global node packages
38+
# RUN sudo -u node npm install -g <your-package-list-here>

.devcontainer/devcontainer.json

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
{
2+
"name": "Hugo (Community)",
3+
"build": {
4+
"dockerfile": "Dockerfile",
5+
"args": {
6+
// Update VARIANT to pick hugo variant.
7+
// Example variants: hugo, hugo_extended
8+
// Rebuild the container if it already exists to update.
9+
"VARIANT": "hugo_extended",
10+
// Update VERSION to pick a specific hugo version.
11+
// Example versions: latest, 0.73.0, 0,71.1
12+
// Rebuild the container if it already exists to update.
13+
"VERSION": "latest",
14+
// Update NODE_VERSION to pick the Node.js version: 12, 14
15+
"NODE_VERSION": "22"
16+
}
17+
},
18+
// Configure tool-specific properties.
19+
"customizations": {
20+
// Configure properties specific to VS Code.
21+
"vscode": {
22+
// Set *default* container specific settings.json values on container create.
23+
"settings": {
24+
"html.format.templating": true
25+
},
26+
// Add the IDs of extensions you want installed when the container is created.
27+
"extensions": [
28+
"tamasfe.even-better-toml",
29+
"davidanson.vscode-markdownlint"
30+
]
31+
}
32+
},
33+
// Use 'forwardPorts' to make a list of ports inside the container available locally.
34+
"forwardPorts": [
35+
1313
36+
],
37+
// Use 'postCreateCommand' to run commands after the container is created.
38+
// "postCreateCommand": "uname -a",
39+
// Set `remoteUser` to `root` to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
40+
"remoteUser": "node",
41+
"features": {
42+
"ghcr.io/devcontainers/features/go:1": {},
43+
"ghcr.io/prplecake/devcontainer-features/dart-sass:1": {}
44+
}
45+
}

.github/workflows/deploy.yml

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
name: Build and deploy
2+
on:
3+
push:
4+
branches:
5+
- main
6+
- master
7+
workflow_dispatch:
8+
permissions:
9+
contents: read
10+
pages: write
11+
id-token: write
12+
concurrency:
13+
group: pages
14+
cancel-in-progress: false
15+
defaults:
16+
run:
17+
shell: bash
18+
jobs:
19+
build:
20+
runs-on: ubuntu-latest
21+
env:
22+
DART_SASS_VERSION: 1.97.1
23+
GO_VERSION: 1.25.5
24+
HUGO_VERSION: 0.154.2
25+
NODE_VERSION: 24.12.0
26+
TZ: Europe/Oslo
27+
steps:
28+
- name: Checkout
29+
uses: actions/checkout@v5
30+
with:
31+
submodules: recursive
32+
fetch-depth: 0
33+
- name: Setup Go
34+
uses: actions/setup-go@v5
35+
with:
36+
go-version: ${{ env.GO_VERSION }}
37+
cache: false
38+
- name: Setup Node.js
39+
uses: actions/setup-node@v4
40+
with:
41+
node-version: ${{ env.NODE_VERSION }}
42+
- name: Setup Pages
43+
id: pages
44+
uses: actions/configure-pages@v5
45+
- name: Create directory for user-specific executable files
46+
run: |
47+
mkdir -p "${HOME}/.local"
48+
- name: Install Dart Sass
49+
run: |
50+
curl -sLJO "https://github.com/sass/dart-sass/releases/download/${DART_SASS_VERSION}/dart-sass-${DART_SASS_VERSION}-linux-x64.tar.gz"
51+
tar -C "${HOME}/.local" -xf "dart-sass-${DART_SASS_VERSION}-linux-x64.tar.gz"
52+
rm "dart-sass-${DART_SASS_VERSION}-linux-x64.tar.gz"
53+
echo "${HOME}/.local/dart-sass" >> "${GITHUB_PATH}"
54+
- name: Setup Hugo
55+
uses: peaceiris/actions-hugo@v3
56+
with:
57+
hugo-version: 'latest'
58+
extended: true
59+
- name: Verify installations
60+
run: |
61+
echo "Dart Sass: $(sass --version)"
62+
echo "Go: $(go version)"
63+
echo "Hugo: $(hugo version)"
64+
echo "Node.js: $(node --version)"
65+
- name: Install Node.js dependencies
66+
run: |
67+
[[ -f package-lock.json || -f npm-shrinkwrap.json ]] && npm ci || true
68+
- name: Configure Git
69+
run: |
70+
git config core.quotepath false
71+
- name: Cache restore
72+
id: cache-restore
73+
uses: actions/cache/restore@v4
74+
with:
75+
path: ${{ runner.temp }}/hugo_cache
76+
key: hugo-${{ github.run_id }}
77+
restore-keys:
78+
hugo-
79+
- name: Build the site
80+
run: |
81+
hugo \
82+
--gc \
83+
--minify \
84+
--baseURL "${{ steps.pages.outputs.base_url }}/" \
85+
--cacheDir "${{ runner.temp }}/hugo_cache"
86+
- name: Cache save
87+
id: cache-save
88+
uses: actions/cache/save@v4
89+
with:
90+
path: ${{ runner.temp }}/hugo_cache
91+
key: ${{ steps.cache-restore.outputs.cache-primary-key }}
92+
- name: Upload artifact
93+
uses: actions/upload-pages-artifact@v3
94+
with:
95+
path: ./public
96+
deploy:
97+
environment:
98+
name: github-pages
99+
url: ${{ steps.deployment.outputs.page_url }}
100+
runs-on: ubuntu-latest
101+
needs: build
102+
steps:
103+
- name: Deploy to GitHub Pages
104+
id: deployment
105+
uses: actions/deploy-pages@v4

.github/workflows/update-theme.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Update theme
2+
3+
# Controls when the workflow will run
4+
on:
5+
schedule:
6+
# Update theme automatically everyday at 00:00 UTC
7+
- cron: "0 0 * * *"
8+
# Allows you to run this workflow manually from the Actions tab
9+
workflow_dispatch:
10+
11+
jobs:
12+
update-theme:
13+
runs-on: ubuntu-latest
14+
15+
permissions:
16+
# Give the default GITHUB_TOKEN write permission to commit and push the
17+
# added or changed files to the repository.
18+
contents: write
19+
20+
steps:
21+
- uses: actions/checkout@v4
22+
23+
- name: Setup Hugo
24+
uses: peaceiris/actions-hugo@v3
25+
with:
26+
hugo-version: 'latest'
27+
extended: true
28+
29+
- name: Update theme
30+
run: hugo mod get -u
31+
32+
- name: Tidy go.mod, go.sum
33+
run: hugo mod tidy
34+
35+
- name: Commit changes
36+
uses: stefanzweifel/git-auto-commit-action@v5
37+
with:
38+
commit_message: "CI: Update theme"

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
public
2+
resources
3+
.hugo_build.lock
4+
.DS_Store
5+
assets/jsconfig.json

.vscode/tasks.json

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
// See https://go.microsoft.com/fwlink/?LinkId=733558
3+
// for the documentation about the tasks.json format
4+
"version": "2.0.0",
5+
"tasks": [
6+
{
7+
"label": "Serve Drafts",
8+
"type": "shell",
9+
"command": "hugo server -D",
10+
"group": {
11+
"kind": "test",
12+
"isDefault": true
13+
},
14+
"isBackground": true,
15+
"problemMatcher": []
16+
},
17+
{
18+
"label": "Build",
19+
"type": "shell",
20+
"command": "hugo",
21+
"group": {
22+
"kind": "build",
23+
"isDefault": true
24+
},
25+
"problemMatcher": []
26+
}
27+
]
28+
}

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2021 Jimmy Cai
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<img align="right" width="150" alt="logo" src="https://user-images.githubusercontent.com/5889006/190859553-5b229b4f-c476-4cbd-928f-890f5265ca4c.png">
2+
3+
# Hugo Theme Stack Starter Template
4+
5+
This is a quick start template for [Hugo theme Stack](https://github.com/CaiJimmy/hugo-theme-stack). It uses [Hugo modules](https://gohugo.io/hugo-modules/) feature to load the theme.
6+
7+
It comes with a basic theme structure and configuration. GitHub action has been set up to deploy the theme to a public GitHub page automatically. Also, there's a cron job to update the theme automatically everyday.
8+
9+
## Video Tutorial
10+
11+
In case you got lost during the setup process, here's a video tutorial that setups a new Hugo site using this template, and deploys it to GitHub Pages: https://www.youtube.com/watch?v=8qDdQQ6Ifxo
12+
13+
## Get started
14+
15+
1. Click *Use this template*, and create your repository as `<username>.github.io` on GitHub. (You can also use a different repository name, but then the resulting website will be available at `https://<username>.github.io/<repository-name>`. )
16+
![Step 1](https://user-images.githubusercontent.com/5889006/156916624-20b2a784-f3a9-4718-aa5f-ce2a436b241f.png)
17+
18+
2. Once the repository is created, create a GitHub codespace associated with it.
19+
![Create codespace](https://user-images.githubusercontent.com/5889006/156916672-43b7b6e9-4ffb-4704-b4ba-d5ca40ffcae7.png)
20+
21+
3. While waiting for the codespace to be created, go to `Settings` -> `Pages` of your newly created repository, and set `Build and deployment` -> `Source` to `GitHub Actions`.
22+
![Change build and deployment source](https://github.com/user-attachments/assets/192459bf-25d8-441e-8029-c108d789e449)
23+
24+
4. After the codespace is created, you can test that the site is built successfully by running `hugo server` in the terminal and see your new site in action.
25+
26+
5. Check `config` folder for the configuration files. You can edit them to suit your needs. Make sure to update the `baseurl` property in `config/_default/config.toml` to your site's URL. For example, if your new repository is named `my-blog`, then the `baseurl` should be `https://<username>.github.io/my-blog/`.
27+
28+
6. Once you're done editing the site, just commit it and push it. GitHub action will deploy the site automatically to GitHub page asociated with the repository.
29+
30+
---
31+
32+
In case you don't want to use GitHub codespace, you can also run this template in your local machine. **You need to install Git, Go and Hugo extended locally.** For more information, check official Hugo documentation: https://gohugo.io/installation/
33+
34+
## Update theme manually
35+
36+
Run:
37+
38+
```bash
39+
hugo mod get -u github.com/CaiJimmy/hugo-theme-stack/v4
40+
hugo mod tidy
41+
```
42+
43+
> This starter template has been configured with `v4` version of theme. Due to the limitation of Go module, once the `v4` or up version of theme is released, you need to update the theme manually. (Modifying `config/module.toml` file)
44+
45+
## Deploy to another static page hostings
46+
47+
Check official Hugo documentation: https://gohugo.io/host-and-deploy/

assets/img/avatar.png

410 Bytes
Loading

assets/img/favicon.png

639 Bytes
Loading

0 commit comments

Comments
 (0)