mirror of
https://github.com/gohugoio/hugo.git
synced 2026-08-24 15:28:54 +00:00
e7afabb927
0755fb534 misc: Update docs.yaml f0c69a38c content: Remove outdated content 43ce895b9 content: Remove outdated new-in badges c3a382fb7 content: Improve GitLab Pages workflow example f2a851966 content: Update Vimeo example 044565ab3 content: Fix typo 9f5e8b5f4 content: Update version references 9dc30f225 theme: Address deprecations in v0.158.0 ea0787a6b content: Document css.Build function f98e4f55c content: Standardize Node.js references bf683e36f content: Use consistent file system terminology 54ed4c12b content: Document strings.ReplacePairs 779d37978 all: Miscellaneous updates for v0.158.0 be1a20c27 Update HUGO_VERSION to 0.158.0 24cdd7bf7 Fix typos in module configuration documentation ce37e7b05 content: Address Markdown linting error 592049f02 content: Remove unnecessary workflow customization section b17b18ce1 content: Update version references in hosting guides 32ec89596 content: Improve urls.PathEscape/PathUnescape examples 9297bb6fa content: Clarify page collection sort order 60192a16f content: Add reference link to glossary term 63d4a992a content: Update documentation contribution guide 946273d67 theme: Adjust feature state notices d70dfd651 theme: Simplify border classes per Tailwind linter fc53c7263 theme: Refactor feature status shortcodes 850dc5b2b content: Clean up content for deprecated features 35da1aa3c content: Miscellaneous udpates for v0.157.0 05b69f84e content: More site-to-project changes 291ffc3f6 content: Add blogger2hugo migration tool 53a1bdee3 Update HUGO_VERSION to 0.157.0 808f0431d Merge branch 'tempv0.157.0' f02222e46 docs: Regen and fix the imaging docshelper output b0d3364f1 Merge commit '0c2fa2460f485e0eca564dcccf36d34538374922' d1f37cc6d resources/images: Adjust WebP processing defaults 9a9f02fb8 Add per-request timeout option to `resources.GetRemote` 900c10201 docs: Fix lineNos default value in docs.yaml 0052c975a docs: Regenerate docs.yaml 3e2f98235 Merge commit '8f3c066d23f431fb2c53d97ea489e4c28b42bd82' dbfd34a1a docs: Update docs.yaml 7e1a08e54 Merge commit '08e1ea5c709d3d49bdc3ce3c21e8fa05a33150d0' cb6e0a42a tpl: Add missing functions to init files 05544e400 markup/asciidocext: Improve Asciidoctor integration 820b5536a github: Add ai-watchdog workflow and update other workflows' versions 3848aec5f markup/goldmark: Enhance footnote extension with backlinkHTML option 070074dac markup/goldmark: Enhance footnote extension with auto-prefixing option f92f7ac5c config/security: Add PROGRAMDATA to the osenv allowlist d1ab84530 minifiers: Update deprecation handling 6c911d1e5 Merge commit 'bfa74537929f409fca841540b971125b7678963a' 61916ab4c resources/page: Add :sectionslug and :sectionslugs permalink tokens 80667667c Add Ancestors (plural) method to GitInfo, rename Ancestor field to Parent e8fdc1d4d source: Expose Ancestor in GitInfo 079671b41 Merge commit 'bb147f91ee9078e6a55e8c32ab4b2e5dbc5cee45' 9e8a08520 images: Add option for vertical alignment to images.Text f7c795479 Merge commit 'b3d87dd0fd746f07f9afa6e6a2969aea41da6a38' 283e97783 Merge commit '5be51ac3db225d5df501ed1fa1499c41d97dbf65' 4c6ec5c19 resources/page: Revise the new contentbasename permalinks tokens fc69d3981 resources/page: Add :contentbasename and :contentbasenameorslug permalink tokens c5f654716 modules: Add GOAUTH to module config 2a1a832fb js/esbuild: Add drop option d9fb55352 Merge commit 'a024bc7d76fcc5e49e8210f9b0896db9ef21861a' 84678f5af helpers: Add Chroma styles to docs.yaml fc8d9e344 Merge commit '346b60358dd8ec2ca228e6635bff9d7914b398b7' 4e4da5e47 Merge commit '81a7b6390036138356773c87a886679c81c524e1' 5df38fde0 docs: Regen CLI docs 3b0f8034b tpl/images: Change signature of images.QR to images.QR TEXT OPTIONS 68187036f images.Text: Add "alignx" option for horizontal alignment 240a85734 docs: Regen CLI docs 21b2917c6 Merge commit 'e9fbadacc3f09191e2e19f112a49777eeb8df06c' 5cc7ad562 tpl/images: Add images.QR function 9b588ee9e Update gocloud and docs for S3-Compatible Endpoints b24377040 tpl/tplimpl: Update details shortcode 0535f4b22 tpl/tplimpl: Add details shortcode 2dd21cf90 Merge commit 'e477373487abcccdbed95688e37aa74b9b8fc198' 869321ffa dartsass: Add silenceDeprecations option 492981933 Merge commit '838bd312b1a287bb33962ad478dbc54737654f35' c79b7d840 docs: Regen CLI docs 101410f08 docs: Regenerate CLI docs 700846bc9 Merge commit 'de0df119b504a91c9e1f442b07954f366ffb2932' 1fb46bb7c docs: Regen CLI docs 923fd9044 commands: Add "hugo build" as an alias for "hugo" 244ea3067 Merge commit '39fd3b557014e339bc6c68a7ff34a7734a735ee0' f2e8913d2 Add support for Obsidian type blockquote alerts 9777cfa83 Merge commit 'dec8cd4ada29218971743333f8ac662a9c06aad8' b3f6d546c output: Fix docshelper template lookup order for AMP pages 476507712 Add config options page.nextPrevSortOrder/nextPrevInSectionSortOrder b2507b8ab tpl/transform: Make Plainify and ToMath return template.HTML 154525780 docs: Regen docshelper 9d9a0848c Merge commit 'a6e635ca7d905d9ec3ffd708db2694f680b03aae' b56a8baa1 math: Add trigonometric functions and some angle helper functions 59f708c0e source: Expose GitInfo Body 7a330c378 Merge commit '8b9803425e63e1b1801f8d5d676e96368d706722' 1ea10926d deploy: Add stripIndexHtml target option 903da161a markup/goldmark: Add the Hugo Goldmark Extras "delete" extension 63cf1ea35 deps: Upgrade github.com/alecthomas/chroma v2.13.0 => v2.14.0 6dcbebe11 config: Remove extraneous BuildConfig setting 1c89b76c2 docs: Regen docshelper 976b30877 markup/goldmark: Support extras extension 0da4eee49 commands: Add gen chromastyles --lineNumbersTableStyle flag daf545b56 docs: Regen docshelper a46a8ac97 all: Fix duplicate words in comments 9a3c76650 tpl/tplimpl: Optionally exclude content from sitemap 737b3b210 tpl/tplimpl: Update Google Analytics template and config 9283d3071 docs: Regen CLI docs fa0437be3 docs: Regen docshelper c318cd850 docs: Fix hyphens and grammar in synopsis of command 'hugo server' 5896f23a9 js: Support JSX and JSXImportSourceOptions 08b0bca77 Merge commit '2658a71e1b6fe24a8b754a62ce0398a09d270d86' c4c5be6c2 docs: Regen docshelper ec07d66fe Add images.Dither filter 3b23f2b89 docs: Regen CLI docs d1c5d6a5e docs: Regenerate docshelper 6c8c9da77 Merge commit '6efb279bfacbd7304cef994be8181c6f804e7dd4' 5ce83ee91 docs: Make null booleans falsy in the docs helper 1185cfc71 docs: Regen docs helper aab11aad7 Merge commit '9b0050e9aabe4be65c78ccf292a348f309d50ccd' as 'docs' git-subtree-dir: docs git-subtree-split: 0755fb534d8b4cde8a0227698da634e3536283ff
197 lines
6.8 KiB
Markdown
197 lines
6.8 KiB
Markdown
---
|
|
title: Host on GitHub Pages
|
|
description: Host your site on GitHub Pages.
|
|
categories: []
|
|
keywords: []
|
|
aliases: [/hosting-and-deployment/hosting-on-github/]
|
|
---
|
|
|
|
## Types of sites
|
|
|
|
There are three types of GitHub Pages sites: project, user, and organization. Project sites are connected to a specific project hosted on GitHub. User and organization sites are connected to a specific account on GitHub.com.
|
|
|
|
> [!note]
|
|
> See the [GitHub Pages documentation] to understand the requirements for repository ownership and naming.
|
|
|
|
## Prerequisites
|
|
|
|
Please complete the following tasks before continuing:
|
|
|
|
1. [Create](https://github.com/signup) a GitHub account
|
|
1. [Log in](https://github.com/login) to your GitHub account
|
|
1. [Create](https://github.com/new) a GitHub repository for your project
|
|
1. [Create](https://git-scm.com/docs/git-init) a local Git repository for your project with a [remote](https://git-scm.com/docs/git-remote) reference to your GitHub repository
|
|
1. Create a Hugo project within your local Git repository and test it with the `hugo server` command
|
|
1. Commit the changes to your local Git repository and push to your GitHub repository
|
|
|
|
## Procedure
|
|
|
|
Step 1
|
|
: Visit your GitHub repository. From the main menu choose **Settings** > **Pages**. In the center of your screen you will see this:
|
|
|
|

|
|
|
|
Change the **Source** to `GitHub Actions`. The change is immediate; you do not have to press a Save button.
|
|
|
|

|
|
|
|
Step 2
|
|
: In your project configuration, change the location of the image cache to the [`cacheDir`] as shown below:
|
|
|
|
{{< code-toggle file=hugo copy=true >}}
|
|
[caches.images]
|
|
dir = ':cacheDir/images'
|
|
{{< /code-toggle >}}
|
|
|
|
See [configure file caches] for more information.
|
|
|
|
Step 3
|
|
: Create a file named `hugo.yaml` in a directory named `.github/workflows`.
|
|
|
|
```text
|
|
mkdir -p .github/workflows
|
|
touch .github/workflows/hugo.yaml
|
|
```
|
|
|
|
Step 4
|
|
: Copy and paste the YAML below into the file you created.
|
|
|
|
```yaml {file=".github/workflows/hugo.yaml" copy=true}
|
|
name: Build and deploy
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
workflow_dispatch:
|
|
permissions:
|
|
contents: read
|
|
pages: write
|
|
id-token: write
|
|
concurrency:
|
|
group: pages
|
|
cancel-in-progress: false
|
|
defaults:
|
|
run:
|
|
shell: bash
|
|
jobs:
|
|
build:
|
|
runs-on: ubuntu-latest
|
|
env:
|
|
DART_SASS_VERSION: 1.98.0
|
|
GO_VERSION: 1.26.1
|
|
HUGO_VERSION: 0.158.0
|
|
NODE_VERSION: 24.14.0
|
|
TZ: Europe/Oslo
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v6
|
|
with:
|
|
submodules: recursive
|
|
fetch-depth: 0
|
|
- name: Setup Go
|
|
uses: actions/setup-go@v6
|
|
with:
|
|
go-version: ${{ env.GO_VERSION }}
|
|
cache: false
|
|
- name: Setup Node.js
|
|
uses: actions/setup-node@v6
|
|
with:
|
|
node-version: ${{ env.NODE_VERSION }}
|
|
- name: Setup Pages
|
|
id: pages
|
|
uses: actions/configure-pages@v5
|
|
- name: Create directory for user-specific executable files
|
|
run: |
|
|
mkdir -p "${HOME}/.local"
|
|
- name: Install Dart Sass
|
|
run: |
|
|
curl -sLJO "https://github.com/sass/dart-sass/releases/download/${DART_SASS_VERSION}/dart-sass-${DART_SASS_VERSION}-linux-x64.tar.gz"
|
|
tar -C "${HOME}/.local" -xf "dart-sass-${DART_SASS_VERSION}-linux-x64.tar.gz"
|
|
rm "dart-sass-${DART_SASS_VERSION}-linux-x64.tar.gz"
|
|
echo "${HOME}/.local/dart-sass" >> "${GITHUB_PATH}"
|
|
- name: Install Hugo
|
|
run: |
|
|
curl -sLJO "https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_extended_${HUGO_VERSION}_linux-amd64.tar.gz"
|
|
mkdir "${HOME}/.local/hugo"
|
|
tar -C "${HOME}/.local/hugo" -xf "hugo_extended_${HUGO_VERSION}_linux-amd64.tar.gz"
|
|
rm "hugo_extended_${HUGO_VERSION}_linux-amd64.tar.gz"
|
|
echo "${HOME}/.local/hugo" >> "${GITHUB_PATH}"
|
|
- name: Verify installations
|
|
run: |
|
|
echo "Dart Sass: $(sass --version)"
|
|
echo "Go: $(go version)"
|
|
echo "Hugo: $(hugo version)"
|
|
echo "Node.js: $(node --version)"
|
|
- name: Install Node.js dependencies
|
|
run: |
|
|
[[ -f package-lock.json || -f npm-shrinkwrap.json ]] && npm ci || true
|
|
- name: Configure Git
|
|
run: |
|
|
git config core.quotepath false
|
|
- name: Cache restore
|
|
id: cache-restore
|
|
uses: actions/cache/restore@v5
|
|
with:
|
|
path: ${{ runner.temp }}/hugo_cache
|
|
key: hugo-${{ github.run_id }}
|
|
restore-keys:
|
|
hugo-
|
|
- name: Build the site
|
|
run: |
|
|
hugo build \
|
|
--gc \
|
|
--minify \
|
|
--baseURL "${{ steps.pages.outputs.base_url }}/" \
|
|
--cacheDir "${{ runner.temp }}/hugo_cache"
|
|
- name: Cache save
|
|
id: cache-save
|
|
uses: actions/cache/save@v5
|
|
with:
|
|
path: ${{ runner.temp }}/hugo_cache
|
|
key: ${{ steps.cache-restore.outputs.cache-primary-key }}
|
|
- name: Upload artifact
|
|
uses: actions/upload-pages-artifact@v3
|
|
with:
|
|
path: ./public
|
|
deploy:
|
|
environment:
|
|
name: github-pages
|
|
url: ${{ steps.deployment.outputs.page_url }}
|
|
runs-on: ubuntu-latest
|
|
needs: build
|
|
steps:
|
|
- name: Deploy to GitHub Pages
|
|
id: deployment
|
|
uses: actions/deploy-pages@v4
|
|
```
|
|
|
|
Step 5
|
|
: Commit the changes to your local Git repository and push to your GitHub repository.
|
|
|
|
Step 6
|
|
: From GitHub's main menu, choose **Actions**. You will see something like this:
|
|
|
|

|
|
|
|
Step 7
|
|
: When GitHub has finished building and deploying your site, the color of the status indicator will change to green.
|
|
|
|

|
|
|
|
Step 8
|
|
: Click on the commit message as shown above. Under the deploy step, you will see a link to your live site.
|
|
|
|

|
|
|
|
In the future, whenever you push a change from your local Git repository, GitHub Pages will rebuild and deploy your site.
|
|
|
|
## Other resources
|
|
|
|
- [Learn more about GitHub Actions](https://docs.github.com/en/actions)
|
|
- [Caching dependencies to speed up workflows](https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows)
|
|
- [Manage a custom domain for your GitHub Pages site](https://docs.github.com/en/pages/configuring-a-custom-domain-for-your-github-pages-site/about-custom-domains-and-github-pages)
|
|
|
|
[`cacheDir`]: /configuration/all/#cachedir
|
|
[configure file caches]: /configuration/caches/
|
|
[GitHub Pages documentation]: https://docs.github.com/en/pages/getting-started-with-github-pages/about-github-pages#types-of-github-pages-sites
|