Merge commit '8b9803425e63e1b1801f8d5d676e96368d706722'
@@ -1,12 +1,12 @@
|
||||
---
|
||||
title: Hosting and deployment
|
||||
linkTitle: Overview
|
||||
linkTitle: In this section
|
||||
description: Site builds, automated deployments, and popular hosting solutions.
|
||||
categories: []
|
||||
keywords: []
|
||||
menu:
|
||||
docs:
|
||||
identifier: hosting-and-deployment-overview
|
||||
identifier: hosting-and-deployment-in-this-section
|
||||
parent: hosting-and-deployment
|
||||
weight: 1
|
||||
weight: 1
|
||||
|
@@ -1,8 +1,8 @@
|
||||
---
|
||||
title: Host on GitHub Pages
|
||||
description: Deploy Hugo as a GitHub Pages project or personal/organizational site and automate the whole process with GitHub Actions
|
||||
description: Host your site on GitHub Pages with continuous deployment using project, user, or organization pages.
|
||||
categories: [hosting and deployment]
|
||||
keywords: [hosting,github]
|
||||
keywords: [hosting]
|
||||
menu:
|
||||
docs:
|
||||
parent: hosting-and-deployment
|
||||
@@ -10,8 +10,6 @@ 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 automating development workflows and build with GitHub Actions.
|
||||
|
||||
## Prerequisites
|
||||
|
||||
1. [Create a GitHub account]
|
||||
@@ -99,7 +97,7 @@ jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
HUGO_VERSION: 0.122.0
|
||||
HUGO_VERSION: 0.127.0
|
||||
steps:
|
||||
- name: Install Hugo CLI
|
||||
run: |
|
||||
@@ -122,13 +120,14 @@ jobs:
|
||||
# For maximum backward compatibility with Hugo modules
|
||||
HUGO_ENVIRONMENT: production
|
||||
HUGO_ENV: production
|
||||
TZ: America/Los_Angeles
|
||||
run: |
|
||||
hugo \
|
||||
--gc \
|
||||
--minify \
|
||||
--baseURL "${{ steps.pages.outputs.base_url }}/"
|
||||
- name: Upload artifact
|
||||
uses: actions/upload-pages-artifact@v2
|
||||
uses: actions/upload-pages-artifact@v3
|
||||
with:
|
||||
path: ./public
|
||||
|
||||
@@ -142,7 +141,7 @@ jobs:
|
||||
steps:
|
||||
- name: Deploy to GitHub Pages
|
||||
id: deployment
|
||||
uses: actions/deploy-pages@v3
|
||||
uses: actions/deploy-pages@v4
|
||||
{{< /code >}}
|
||||
|
||||
Step 7
|
||||
|
@@ -27,8 +27,8 @@ Define your [CI/CD](https://docs.gitlab.com/ee/ci/quick_start/) jobs by creating
|
||||
|
||||
{{< code file=.gitlab-ci.yml copy=true >}}
|
||||
variables:
|
||||
DART_SASS_VERSION: 1.70.0
|
||||
HUGO_VERSION: 0.122.0
|
||||
DART_SASS_VERSION: 1.77.1
|
||||
HUGO_VERSION: 0.126.0
|
||||
NODE_VERSION: 20.x
|
||||
GIT_DEPTH: 0
|
||||
GIT_STRATEGY: clone
|
||||
@@ -36,7 +36,7 @@ variables:
|
||||
TZ: America/Los_Angeles
|
||||
|
||||
image:
|
||||
name: golang:1.20.6-bookworm
|
||||
name: golang:1.22.1-bookworm
|
||||
|
||||
pages:
|
||||
script:
|
||||
|
@@ -1,145 +0,0 @@
|
||||
---
|
||||
title: Host on Netlify
|
||||
description: Netlify can host your Hugo site with CDN, continuous deployment, 1-click HTTPS, an admin GUI, and its own CLI.
|
||||
categories: [hosting and deployment]
|
||||
keywords: [hosting,netlify]
|
||||
menu:
|
||||
docs:
|
||||
parent: hosting-and-deployment
|
||||
toc: true
|
||||
---
|
||||
|
||||
[Netlify][netlify] provides continuous deployment services, global CDN, ultra-fast DNS, atomic deploys, instant cache invalidation, one-click SSL, a browser-based interface, a CLI, and many other features for managing your Hugo website.
|
||||
|
||||
## Assumptions
|
||||
|
||||
* You have an account with GitHub, GitLab, or Bitbucket.
|
||||
* You have completed the [Quick Start] or have a Hugo website you are ready to deploy and share with the world.
|
||||
* You do not already have a Netlify account.
|
||||
|
||||
## Create a Netlify account
|
||||
|
||||
Go to [app.netlify.com] and select your preferred sign up method. This will likely be a hosted Git provider, although you also have the option to sign up with an email address.
|
||||
|
||||
The following examples use GitHub, but other git providers will follow a similar process.
|
||||
|
||||

|
||||
|
||||
Selecting GitHub will bring up an authorization modal for authentication. Select "Authorize application."
|
||||
|
||||

|
||||
|
||||
## Create a new site with continuous deployment
|
||||
|
||||
You're now already a Netlify member and should be brought to your new dashboard. Select "New site from git."
|
||||
|
||||

|
||||
|
||||
Netlify will then start walking you through the steps necessary for continuous deployment. First, you'll need to select your git provider again, but this time you are giving Netlify added permissions to your repositories.
|
||||
|
||||

|
||||
|
||||
And then again with the GitHub authorization modal:
|
||||
|
||||

|
||||
|
||||
Select the repo you want to use for continuous deployment. If you have a large number of repositories, you can filter through them in real time using repo search:
|
||||
|
||||

|
||||
|
||||
Once selected, you'll be brought to a screen for basic setup. Here you can select the branch you want to publish, your [build command], and your publish (i.e. deploy) directory. The publish directory should mirror that of what you've set in your [site configuration], the default of which is `public`. The following steps assume you are publishing from the `master` branch.
|
||||
|
||||
## Configure Hugo version in Netlify
|
||||
|
||||
You can [set Hugo version](https://www.netlify.com/blog/2017/04/11/netlify-plus-hugo-0.20-and-beyond/) for your environments in `netlify.toml` file or set `HUGO_VERSION` as a build environment variable in the Netlify console.
|
||||
|
||||
For production:
|
||||
|
||||
{{< code file=netlify.toml >}}
|
||||
[context.production.environment]
|
||||
HUGO_VERSION = "0.122.0"
|
||||
{{< /code >}}
|
||||
|
||||
For testing:
|
||||
|
||||
{{< code file=netlify.toml >}}
|
||||
[context.deploy-preview.environment]
|
||||
HUGO_VERSION = "0.122.0"
|
||||
{{< /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`:
|
||||
|
||||
{{< readfile file=netlify.toml highlight=toml >}}
|
||||
|
||||
## Build and deploy site
|
||||
|
||||
In the Netlify console, selecting "Deploy site" will immediately take you to a terminal for your build:.
|
||||
|
||||

|
||||
|
||||
Once the build is finished---this should only take a few seconds--you should now see a "Hero Card" at the top of your screen letting you know the deployment is successful. The Hero Card is the first element that you see in most pages. It allows you to see a quick summary of the page and gives access to the most common/pertinent actions and information. You'll see that the URL is automatically generated by Netlify. You can update the URL in "Settings."
|
||||
|
||||

|
||||
|
||||

|
||||
|
||||
[Visit the live site][visit].
|
||||
|
||||
Now every time you push changes to your hosted git repository, Netlify will rebuild and redeploy your site.
|
||||
|
||||
See [this blog post](https://www.netlify.com/blog/2017/04/11/netlify-plus-hugo-0.20-and-beyond/) for more details about how Netlify handles Hugo versions.
|
||||
|
||||
## Use Hugo themes with Netlify
|
||||
|
||||
The `git clone` method for installing themes is not supported by Netlify. If you were to use `git clone`, it would require you to recursively remove the `.git` subdirectory from the theme folder and would therefore prevent compatibility with future versions of the theme.
|
||||
|
||||
A *better* approach is to install a theme as a proper git submodule. You can [read the GitHub documentation for submodules][ghsm] or those found on [Git's website][gitsm] for more information, but the command is similar to that of `git clone`:
|
||||
|
||||
```txt
|
||||
cd themes
|
||||
git submodule add https://github.com/<THEMECREATOR>/<THEMENAME>
|
||||
```
|
||||
|
||||
It is recommended to only use stable versions of a theme (if it’s versioned) and always check the changelog. This can be done by checking out a specific release within the theme's directory.
|
||||
|
||||
Switch to the theme's directory and list all available versions:
|
||||
|
||||
```txt
|
||||
cd themes/<theme>
|
||||
git tag
|
||||
# exit with q
|
||||
```
|
||||
|
||||
You can checkout a specific version as follows:
|
||||
|
||||
```txt
|
||||
git checkout tags/<version-name>
|
||||
```
|
||||
|
||||
You can update a theme to the latest version by executing the following command in the *root* directory of your project:
|
||||
|
||||
```txt
|
||||
git submodule update --rebase --remote
|
||||
```
|
||||
|
||||
## Next steps
|
||||
|
||||
You now have a live website served over HTTPS, distributed through CDN, and configured for continuous deployment. Dig deeper into the Netlify documentation:
|
||||
|
||||
1. [Using a Custom Domain]
|
||||
2. [Setting up HTTPS on Custom Domains][httpscustom]
|
||||
3. [Redirects and Rewrite Rules]
|
||||
|
||||
[app.netlify.com]: https://app.netlify.com
|
||||
[build command]: /getting-started/usage/#build-your-site
|
||||
[site configuration]: /getting-started/configuration/
|
||||
[ghsm]: https://github.com/blog/2104-working-with-submodules
|
||||
[gitsm]: https://git-scm.com/book/en/v2/Git-Tools-Submodules
|
||||
[httpscustom]: https://www.netlify.com/docs/ssl/
|
||||
[hugoversions]: https://github.com/netlify/build-image/blob/master/Dockerfile#L216
|
||||
[netlify]: https://www.netlify.com/
|
||||
[netlifysignup]: https://app.netlify.com/signup
|
||||
[Quick Start]: /getting-started/quick-start/
|
||||
[Redirects and Rewrite Rules]: https://www.netlify.com/docs/redirects/
|
||||
[Using a Custom Domain]: https://www.netlify.com/docs/custom-domains/
|
||||
[visit]: https://hugo-netlify-example.netlify.com
|
@@ -0,0 +1,129 @@
|
||||
---
|
||||
title: Host on Netlify
|
||||
description: Host your site on Netlify with continuous deployment.
|
||||
categories: [hosting and deployment]
|
||||
keywords: [hosting]
|
||||
menu:
|
||||
docs:
|
||||
parent: hosting-and-deployment
|
||||
toc: true
|
||||
---
|
||||
|
||||
## Prerequisites
|
||||
|
||||
1. [Create a Netlify account]
|
||||
2. [Install Git]
|
||||
3. [Create a Hugo site] and test it locally with `hugo server`
|
||||
4. Commit the changes to your local repository
|
||||
4. Push the local repository to your [GitHub], [GitLab], or [Bitbucket] account
|
||||
|
||||
[Bitbucket]: https://bitbucket.org/product
|
||||
[Create a Hugo site]: /getting-started/quick-start/
|
||||
[Create a Netlify account]: https://app.netlify.com/signup
|
||||
[GitHub]: https://github.com
|
||||
[GitLab]: https://about.gitlab.com/
|
||||
[Install Git]: https://git-scm.com/book/en/v2/Getting-Started-Installing-Git
|
||||
|
||||
## Procedure
|
||||
|
||||
This procedure will enable continuous deployment from a GitHub repository. The procedure is essentially the same if you are using GitLab or Bitbucket.
|
||||
|
||||
Step 1
|
||||
: Log in to your Netlify account, navigate to the Sites page, press the **Add new site** button, and choose "Import an existing project" from the dropdown menu.
|
||||
|
||||
Step 2
|
||||
: Select your deployment method.
|
||||
|
||||

|
||||
|
||||
Step 3
|
||||
: Authorize Netlify to connect with your GitHub account by pressing the **Authorize Netlify** button.
|
||||
|
||||

|
||||
|
||||
Step 4
|
||||
: Press the **Configure Netlify on GitHub** button.
|
||||
|
||||

|
||||
|
||||
Step 5
|
||||
: Install the Netlify app by selecting your GitHub account.
|
||||
|
||||

|
||||
|
||||
Step 6
|
||||
: Press the **Install** button.
|
||||
|
||||

|
||||
|
||||
Step 7
|
||||
: Click on the site's repository from the list.
|
||||
|
||||

|
||||
|
||||
Step 8
|
||||
: Set the site name and branch from which to deploy.
|
||||
|
||||

|
||||
|
||||
Step 9
|
||||
: Define the build settings, press the **Add environment variables** button, then press the **New variable** button.
|
||||
|
||||

|
||||
|
||||
Step 10
|
||||
: Create a new environment variable named `HUGO_VERSION` and set the value to the [latest version].
|
||||
|
||||
[latest version]: https://github.com/gohugoio/hugo/releases/latest
|
||||
|
||||

|
||||
|
||||
Step 11
|
||||
: Press the "Deploy my new site" button at the bottom of the page.
|
||||
|
||||

|
||||
|
||||
Step 12
|
||||
: At the bottom of the screen, wait for the deploy to complete, then click on the deploy log entry.
|
||||
|
||||

|
||||
|
||||
Step 13
|
||||
: Press the **Open production deploy** button to view the live site.
|
||||
|
||||

|
||||
|
||||
## Configuration file
|
||||
|
||||
In the procedure above we configured our site using the Netlify user interface. Most site owners find it easier to use a configuration file checked into source control.
|
||||
|
||||
Create a new file named netlify.toml in the root of your project directory. In its simplest form, the configuration file might look like this:
|
||||
|
||||
{{< code file=netlify.toml >}}
|
||||
[build.environment]
|
||||
HUGO_VERSION = "0.126.0"
|
||||
TZ = "America/Los_Angeles"
|
||||
|
||||
[build]
|
||||
publish = "public"
|
||||
command = "hugo --gc --minify"
|
||||
{{< /code >}}
|
||||
|
||||
If your site requires Dart Sass to transpile Sass to CSS, the configuration file should look something like this:
|
||||
|
||||
{{< code file=netlify.toml >}}
|
||||
[build.environment]
|
||||
HUGO_VERSION = "0.126.0"
|
||||
DART_SASS_VERSION = "1.77.1"
|
||||
TZ = "America/Los_Angeles"
|
||||
|
||||
[build]
|
||||
publish = "public"
|
||||
command = """\
|
||||
curl -LJO https://github.com/sass/dart-sass/releases/download/${DART_SASS_VERSION}/dart-sass-${DART_SASS_VERSION}-linux-x64.tar.gz && \
|
||||
tar -xf dart-sass-${DART_SASS_VERSION}-linux-x64.tar.gz && \
|
||||
rm dart-sass-${DART_SASS_VERSION}-linux-x64.tar.gz && \
|
||||
export PATH=/opt/build/repo/dart-sass:$PATH && \
|
||||
hugo --gc --minify \
|
||||
"""
|
||||
{{< /code >}}
|
After Width: | Height: | Size: 8.4 KiB |
After Width: | Height: | Size: 16 KiB |
After Width: | Height: | Size: 10 KiB |
After Width: | Height: | Size: 5.0 KiB |
After Width: | Height: | Size: 24 KiB |
After Width: | Height: | Size: 2.9 KiB |
After Width: | Height: | Size: 8.3 KiB |
After Width: | Height: | Size: 12 KiB |
After Width: | Height: | Size: 7.0 KiB |
After Width: | Height: | Size: 2.3 KiB |
After Width: | Height: | Size: 5.7 KiB |
After Width: | Height: | Size: 10 KiB |