generated from hugo-fixit/hugo-fixit-starter
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 22ba2c4
Showing
29 changed files
with
1,657 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# To get started with Dependabot version updates, you'll need to specify which | ||
# package ecosystems to update and where the package manifests are located. | ||
# Please see the documentation for all configuration options: | ||
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates | ||
|
||
version: 2 | ||
updates: | ||
- package-ecosystem: "github-actions" | ||
directory: "/" | ||
schedule: | ||
interval: "monthly" | ||
open-pull-requests-limit: 1000 | ||
assignees: | ||
- "Lruihao" | ||
labels: | ||
- "dependencies" | ||
- package-ecosystem: "gomod" # See documentation for possible values | ||
directory: "/" # Location of package manifests | ||
schedule: | ||
interval: "monthly" | ||
open-pull-requests-limit: 1000 | ||
assignees: | ||
- "Lruihao" | ||
labels: | ||
- "dependencies" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
name: Hugo build and deploy | ||
on: | ||
push: | ||
branches: [ main ] | ||
paths: | ||
- '.github/workflows/deploy.yml' | ||
- 'assets/**' | ||
- 'config/**' | ||
- 'content/**' | ||
- 'data/**' | ||
- 'static/**' | ||
- 'themes/**' | ||
- 'go.mod' | ||
- 'go.sum' | ||
workflow_run: | ||
workflows: ['Update theme'] | ||
types: | ||
- completed | ||
workflow_dispatch: | ||
|
||
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages | ||
permissions: | ||
contents: read | ||
pages: write | ||
id-token: write | ||
|
||
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. | ||
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete. | ||
concurrency: | ||
group: "pages" | ||
cancel-in-progress: false | ||
|
||
jobs: | ||
# Build job | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Cache Hugo resources | ||
uses: actions/cache@v4 | ||
env: | ||
cache-name: cache-hugo-resources | ||
with: | ||
path: resources | ||
key: ${{ env.cache-name }} | ||
- uses: actions/setup-go@v5 | ||
with: | ||
go-version: "^1.17.0" | ||
- run: go version | ||
- name: Cache Go Modules | ||
uses: actions/cache@v4 | ||
with: | ||
path: | | ||
~/.cache/go-build | ||
~/go/pkg/mod | ||
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} | ||
restore-keys: | | ||
${{ runner.os }}-go- | ||
- name: Setup Hugo | ||
uses: peaceiris/actions-hugo@v3 | ||
with: | ||
# use the environment variable HUGO_VERSION as the hugo version, if not set, use `latest`. | ||
hugo-version: ${{ vars.HUGO_VERSION || 'latest' }} | ||
extended: true | ||
- name: Hugo build | ||
run: hugo --gc --minify --logLevel info | ||
- name: Upload artifact | ||
uses: actions/upload-pages-artifact@v3 | ||
with: | ||
# Upload only the public directory | ||
path: './public' | ||
|
||
# Deployment job | ||
deploy: | ||
environment: | ||
name: github-pages | ||
url: ${{ steps.deployment.outputs.page_url }} | ||
runs-on: ubuntu-latest | ||
needs: build | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Deploy to GitHub Pages | ||
id: deployment | ||
uses: actions/deploy-pages@v4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
name: Update theme | ||
|
||
# Controls when the workflow will run | ||
on: | ||
schedule: | ||
# Update theme automatically everyday at 00:00 UTC | ||
- cron: "0 0 * * *" | ||
# Allows you to run this workflow manually from the Actions tab | ||
workflow_dispatch: | ||
|
||
jobs: | ||
Update-FixIt: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Setup Hugo | ||
uses: peaceiris/actions-hugo@v3 | ||
with: | ||
# use the environment variable HUGO_VERSION as the hugo version, if not set, use `latest`. | ||
hugo-version: ${{ vars.HUGO_VERSION || 'latest' }} | ||
extended: true | ||
|
||
- name: Update theme | ||
run: hugo mod get -u github.com/hugo-fixit/FixIt@latest | ||
|
||
- name: Tidy go.mod, go.sum | ||
run: hugo mod tidy | ||
|
||
- name: Commit changes | ||
uses: stefanzweifel/git-auto-commit-action@v5 | ||
with: | ||
commit_message: ':arrow_up: Chore(theme): update FixIt version' | ||
commit_author: 'github-actions[bot] <github-actions[bot]@users.noreply.github.com>' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
node_modules/ | ||
build/ | ||
public/ | ||
resources/ | ||
|
||
.hugo_build.lock | ||
_vendor | ||
jsconfig.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2023-2024 Lruihao (https://lruihao.cn) | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
# Hugo FixIt Blog Template (Go) | ||
|
||
👉 English | [简体中文](README.md) | ||
|
||
This is a quick start template for Hugo theme [FixIt](https://github.com/hugo-fixit/FixIt). It uses [Hugo Modules](https://gohugo.io/hugo-modules/) feature to load the theme. If you favor Git more, you can [check this template](https://github.com/hugo-fixit/hugo-fixit-starter1). | ||
|
||
It comes with a basic theme structure and configuration. GitHub action has been set up to deploy the blog to a public GitHub page automatically. Also, there's a cron job to update the theme automatically everyday. | ||
|
||
## Directory structure | ||
|
||
```bash | ||
▸ .github/ # GitHub configuration | ||
▸ archetypes/ # page archetypes (like scaffolds of archetypes) | ||
▸ assets/ # css, js, third-party libraries etc. | ||
▸ config/ # configuration files | ||
▸ content/ # markdown files for hugo project | ||
▸ data/ # blog data (allow: yaml, json, toml), e.g. friends.yml | ||
▸ public/ # build directory | ||
▸ static/ # static files, e.g. favicon.ico | ||
▸ themes/ # theme submodules | ||
▸ go.mod | ||
▸ go.sum | ||
``` | ||
|
||
## Quick Start | ||
|
||
For a complete quick start, see this [page](https://fixit.lruihao.cn/documentation/getting-started/). | ||
|
||
### Prerequisites | ||
|
||
- [Go](https://go.dev/dl/) | ||
- [Hugo](https://gohugo.io/installation/) (extended version) | ||
|
||
### Use Template | ||
|
||
1. Click [**Use this template**](https://github.com/hugo-fixit/hugo-fixit-starter/generate), and create your repository on GitHub. | ||
|
||
<img width="913" alt="image" src="https://github.com/hugo-fixit/hugo-fixit-starter1/assets/33419593/d5fbd940-3ffd-4750-b1e6-4e87b50b0696"> | ||
|
||
2. Once the repository is created, just clone and enjoy it! | ||
|
||
```bash | ||
# Clone with your own repository url | ||
git clone --recursive https://github.com/<your_name>/<your_blog_repo>.git | ||
``` | ||
|
||
> [!TIP] | ||
> The repository name determines your GitHub Pages URL, for example: | ||
> | ||
> | Repository Name | GitHub Pages | | ||
> | :--- | :--- | | ||
> | `<your_name>.github.io` | `https://<your_name>.github.io/` | | ||
> | `blog` | `https://<your_name>.github.io/blog/` | | ||
|
||
### Launching the Site | ||
|
||
```bash | ||
# Development environment | ||
hugo server | ||
# Production environment | ||
hugo server -e production | ||
``` | ||
|
||
### Build the Site | ||
|
||
When your site is ready to deploy, run the following command: | ||
|
||
```bash | ||
hugo | ||
``` | ||
|
||
### Deploy to GitHub Pages | ||
|
||
> [!NOTE] | ||
> You may have noticed that the first automatic deployment of GitHub Actions after the template initialization failed. This is because you have not configured Workflow permissions and GitHub Pages. | ||
|
||
1. Head to Setting => Actions => General => Workflow permissions => Check "Read and write permissions". | ||
2. GitHub Pages settings: Setting => Pages => Source: GitHub Actions. | ||
3. Modify `config/_default/hugo.toml` file `baseURL` to your site URL. | ||
4. Commit the changes from the previous step to the `main` branch, and GitHub Actions will automatically build and deploy the site to GitHub Pages. | ||
|
||
### Update Theme | ||
|
||
Afterwards you can upgrade the theme with the following command: | ||
|
||
```bash | ||
# Update theme manually | ||
hugo mod get -u github.com/hugo-fixit/FixIt@latest | ||
hugo mod tidy | ||
``` | ||
|
||
<details> | ||
<summary>Start via NPM script</summary> | ||
|
||
```bash | ||
# build the blog | ||
npm run build | ||
# run a local debugging server with watch | ||
npm run server | ||
# run a local debugging server in production environment | ||
npm run server:production | ||
# update theme submodules | ||
npm run update:theme | ||
``` | ||
|
||
</details> | ||
|
||
## Troubleshooting | ||
|
||
<details> | ||
<summary>remote: Permission to git denied to github-actions[bot].</summary> | ||
Head to Setting => Actions => General => Workflow permissions => Check "Read and write permissions". | ||
</details> | ||
|
||
<!-- This project was generated with [hugo-fixit-starter](https://github.com/hugo-fixit/hugo-fixit-starter). --> |
Oops, something went wrong.