Skip to main content

Host on Netlify

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
  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: