Merge commit '32ba623541d74ee0b7ae4efb1b8326dc49af28b8'

This commit is contained in:
Bjørn Erik Pedersen
2021-06-08 18:47:53 +02:00
21 changed files with 981 additions and 84 deletions

View File

@@ -17,7 +17,7 @@ toc: true
aliases: [/tutorials/github-pages-blog/]
---
GitHub provides free and fast static hosting over SSL for personal, organization, or project pages directly from a GitHub repository via its [GitHub Pages service][] and automate development workflows and build with [GitHub Actions].
GitHub provides free and fast static hosting over SSL for personal, organization, or project pages directly from a GitHub repository via its [GitHub Pages service][] and automating development workflows and build with [GitHub Actions].
## Assumptions
@@ -45,9 +45,9 @@ This is a much simpler setup as your Hugo files and generated content are publis
## Build Hugo With GitHub Action
GitHub execute your software development workflows. Everytime you push your code on the Github repository, Github Action will build the site automatically.
GitHub executes your software development workflows. Everytime you push your code on the Github repository, Github Actions will build the site automatically.
Create a file in `.github/workflows/gh-pages.yml` containing the following content (based on https://github.com/marketplace/actions/hugo-setup ):
Create a file in `.github/workflows/gh-pages.yml` containing the following content (based on [actions-hugo](https://github.com/marketplace/actions/hugo-setup)):
```yml
name: github pages
@@ -56,10 +56,11 @@ on:
push:
branches:
- main # Set a branch to deploy
pull_request:
jobs:
deploy:
runs-on: ubuntu-18.04
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
with:
@@ -77,12 +78,13 @@ jobs:
- name: Deploy
uses: peaceiris/actions-gh-pages@v3
if: github.ref == 'refs/heads/main'
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./public
```
For more advanced settings https://github.com/marketplace/actions/hugo-setup
For more advanced settings [actions-hugo](https://github.com/marketplace/actions/hugo-setup) and [actions-gh-pages](https://github.com/marketplace/actions/github-pages-action).
## Use a Custom Domain

View File

@@ -67,14 +67,14 @@ For production:
{{< code file="netlify.toml" codeLang="toml" >}}
[context.production.environment]
HUGO_VERSION = "0.82.1"
HUGO_VERSION = "0.83.1"
{{< /code >}}
For testing:
{{< code file="netlify.toml" codeLang="toml" >}}
[context.deploy-preview.environment]
HUGO_VERSION = "0.82.1"
HUGO_VERSION = "0.83.1"
{{< /code >}}
The Netlify configuration file can be a little hard to understand and get right for the different environment, and you may get some inspiration and tips from this site's `netlify.toml`:

View File

@@ -4,7 +4,7 @@ linktitle: Hugo Deploy
description: You can upload your site to GCS, S3, or Azure using the Hugo CLI.
date: 2019-05-30
publishdate: 2019-05-30
lastmod: 2019-05-30
lastmod: 2021-05-03
categories: [hosting and deployment]
keywords: [s3,gcs,azure,hosting,deployment]
authors: [Robert van Gent]
@@ -95,10 +95,13 @@ cloudFrontDistributionID = <ID>
# [[deployment.matchers]] configure behavior for files that match the Pattern.
# See https://golang.org/pkg/regexp/syntax/ for pattern syntax.
# Pattern searching is stopped on first match.
# Samples:
[[deployment.matchers]]
# Cache static assets for 1 year.
# Cache static assets for 1 year.
pattern = "^.+\\.(js|css|svg|ttf)$"
cacheControl = "max-age=31536000, no-transform, public"
gzip = true
@@ -108,6 +111,12 @@ pattern = "^.+\\.(png|jpg)$"
cacheControl = "max-age=31536000, no-transform, public"
gzip = false
[[deployment.matchers]]
# Set custom content type for /sitemap.xml
pattern = "^sitemap\\.xml$"
contentType = "application/xml"
gzip = true
[[deployment.matchers]]
pattern = "^.+\\.(html|xml|json)$"
gzip = true