hugo/content/en/hosting-and-deployment/hosting-on-netlify/index.md
Bjørn Erik Pedersen e477373487 Squashed 'docs/' changes from 227aab619..8390a4a3a
8390a4a3a Add Void Linux installation instructions
d6099aae8 Update link to PostCSS plugins
25dad4693 netlify: Hugo 0.139.4
2b1fa118c Fix typo
3ef1eb505 Update hosting-on-aws-amplify
c0f6d35d6 Fix typo
aa54d4301 Correct directory name
98aa26bdb Improve instructions for hosting with AWS Amplify
a07638a80 Add new-in badges
6ad018055 netlify: Hugo 0.139.3
1050835d6 Update title of hugo.Store page
ebbd2e851 Clarify the shortcode Ordinal method
b7716ed95 Revise code block render hook for Mermaid diagrams
f1da9b6ea netlify: Hugo 0.139.2
d8ac9f428 Downgrade the Go toolchain in go.mod to a slightly older Go version
254b3c4f2 netlify: Hugo 0.139.1
03e666038 Add hugo.Store, site.Store and Shortcode.Store
157e8983b Update Anchorize.md
59fa9f214 Document the PageRef menu entry method
bda544cce docs(transform.Unmarshal): match lang attribute to title language in examples
1985886bd Adjust front matter of shared Markdown snippets
da5bd70d1 Fix typo
431b65d6b Update theme
b63ef69f5 Update style guidance
d50ed3422 Remove old new-in badges
12bfb9933 Update docs.yaml
0b936cacd netlify: Hugo 0.139.0
ab7668b4d dartsass: Add silenceDeprecations option
154df9bfc Merge commit '838bd312b1'
efa80477c docs: Regen CLI docs
ad99e4a7a docs: Regenerate CLI docs

git-subtree-dir: docs
git-subtree-split: 8390a4a3ac36094f4cf47170af23b636608c420e
2024-12-11 09:53:33 +01:00

3.7 KiB

title description categories keywords menu toc
Host on Netlify Host your site on Netlify with continuous deployment.
hosting and deployment
hosting
docs
parent
hosting-and-deployment
true

Prerequisites

Please complete the following tasks before continuing:

  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
  5. Push the local repository to your GitHub, GitLab, or Bitbucket account

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.

screen capture

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

screen capture

Step 4
Press the Configure Netlify on GitHub button.

screen capture

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

screen capture

Step 6
Press the Install button.

screen capture

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

screen capture

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

screen capture

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

screen capture

Step 10
Create a new environment variable named HUGO_VERSION and set the value to the latest version.

screen capture

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

screen capture

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

screen capture

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

screen capture

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.137.1" 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.137.1" DART_SASS_VERSION = "1.80.6" 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 >}}