| 1 |
--- |
| 2 |
title: Host on Netlify |
| 3 |
description: Host your site on Netlify. |
| 4 |
categories: [] |
| 5 |
keywords: [] |
| 6 |
aliases: [/hosting-and-deployment/hosting-on-netlify/] |
| 7 |
--- |
| 8 |
|
| 9 |
Use these instructions to enable continuous deployment from a GitHub repository. The same general steps apply if you are using Azure DevOps, Bitbucket, or GitLab for version control. |
| 10 |
|
| 11 |
## Prerequisites |
| 12 |
|
| 13 |
Please complete the following tasks before continuing: |
| 14 |
|
| 15 |
1. [Create](https://app.netlify.com/signup) a Netlify account |
| 16 |
1. [Log in](https://app.netlify.com/login) to your Netlify account |
| 17 |
1. [Create](https://github.com/signup) a GitHub account |
| 18 |
1. [Log in](https://github.com/login) to your GitHub account |
| 19 |
1. [Create](https://github.com/new) a GitHub repository for your project |
| 20 |
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 |
| 21 |
1. Create a Hugo project within your local Git repository and test it with the `hugo server` command |
| 22 |
1. Commit the changes to your local Git repository and push to your GitHub repository. |
| 23 |
|
| 24 |
## Procedure |
| 25 |
|
| 26 |
<!-- Using "text" as the code block language because "toml" looks terrible. --> |
| 27 |
|
| 28 |
Step 1 |
| 29 |
: Create a `netlify.toml` file in the root of your project. |
| 30 |
|
| 31 |
```text {file="netlify.toml" copy=true} |
| 32 |
[build.environment] |
| 33 |
DART_SASS_VERSION = "1.99.0" |
| 34 |
GO_VERSION = "1.26.2" |
| 35 |
HUGO_VERSION = "0.161.1" |
| 36 |
NODE_VERSION = "24.15.0" |
| 37 |
TZ = "Europe/Oslo" |
| 38 |
|
| 39 |
[build] |
| 40 |
publish = "public" |
| 41 |
command = """\ |
| 42 |
git config core.quotepath false && \ |
| 43 |
hugo build --gc --minify --baseURL "${URL}" |
| 44 |
""" |
| 45 |
``` |
| 46 |
|
| 47 |
If your site requires Dart Sass to transpile Sass to CSS, set the `DART_SASS_VERSION` and include the Dart Sass installation in the build step. |
| 48 |
|
| 49 |
```text {file="netlify.toml" copy=true} |
| 50 |
[build.environment] |
| 51 |
DART_SASS_VERSION = "1.99.0" |
| 52 |
GO_VERSION = "1.26.2" |
| 53 |
HUGO_VERSION = "0.161.1" |
| 54 |
NODE_VERSION = "24.15.0" |
| 55 |
TZ = "Europe/Oslo" |
| 56 |
|
| 57 |
[build] |
| 58 |
publish = "public" |
| 59 |
command = """\ |
| 60 |
curl -sLJO "https://github.com/sass/dart-sass/releases/download/${DART_SASS_VERSION}/dart-sass-${DART_SASS_VERSION}-linux-x64.tar.gz" && \ |
| 61 |
tar -C "${HOME}/.local" -xf "dart-sass-${DART_SASS_VERSION}-linux-x64.tar.gz" && \ |
| 62 |
rm "dart-sass-${DART_SASS_VERSION}-linux-x64.tar.gz" && \ |
| 63 |
export PATH="${HOME}/.local/dart-sass:${PATH}" && \ |
| 64 |
git config core.quotepath false && \ |
| 65 |
hugo build --gc --minify --baseURL "${URL}" |
| 66 |
""" |
| 67 |
``` |
| 68 |
|
| 69 |
Step 2 |
| 70 |
: Commit the changes to your local Git repository and push to your GitHub repository. |
| 71 |
|
| 72 |
Step 3 |
| 73 |
: In the upper right corner of the Netlify dashboard, press the **Add new project** button and select “Import an existing project". |
| 74 |
|
| 75 |
 |
| 76 |
|
| 77 |
Step 4 |
| 78 |
: Connect to GitHub. |
| 79 |
|
| 80 |
 |
| 81 |
|
| 82 |
Step 5 |
| 83 |
: Press the "Authorize Netlify" button to allow the Netlify application to access your GitHub account. |
| 84 |
|
| 85 |
 |
| 86 |
|
| 87 |
Step 6 |
| 88 |
: Press the **Configure Netlify on GitHub** button. |
| 89 |
|
| 90 |
 |
| 91 |
|
| 92 |
Step 7 |
| 93 |
: Select the GitHub account where you want to install the Netlify application. |
| 94 |
|
| 95 |
 |
| 96 |
|
| 97 |
Step 8 |
| 98 |
: Authorize the Netlify application to access all repositories or only select repositories, then press the Install button. |
| 99 |
|
| 100 |
 |
| 101 |
|
| 102 |
Your browser will be redirected to the Netlify dashboard. |
| 103 |
|
| 104 |
Step 9 |
| 105 |
: Click on the name of the repository you wish to import. |
| 106 |
|
| 107 |
 |
| 108 |
|
| 109 |
Step 10 |
| 110 |
: On the "Review configuration" page, enter a project name, leave the settings at their default values, then press the **Deploy** button. |
| 111 |
|
| 112 |
 |
| 113 |
|
| 114 |
 |
| 115 |
|
| 116 |
Step 11 |
| 117 |
: When the deployment completes, click on the link to your published site. |
| 118 |
|
| 119 |
 |
| 120 |
|
| 121 |
In the future, whenever you push a change from your local Git repository, Netlify will rebuild and deploy your site. |