Netlify offers an excellent and easy process for deploying hugo static site. You can deploy your site in matter of few clicks. Unlike Github Pages, you can name your repository whatever you want. You can also customize the site URL.

In this post, we will show the step-by-step process of deploying a hugo site with netlify.

Add Netlify Configuration

At first, create a netlify.toml file at the root of your repository and add the following configuration there:

command = "hugo --gc --minify"
publish = "public"

HUGO_ENV           = "production"
HUGO_THEME         = "toha"
HUGO_VERSION       = "0.77.0"

command = "hugo --gc --minify --enableGitInfo"

    HUGO_ENV     = "production"
    HUGO_VERSION = "0.77.0"

command = "hugo --gc --minify --buildFuture -b $DEPLOY_PRIME_URL"

    HUGO_VERSION = "0.77.0"

command = "hugo --gc --minify -b $DEPLOY_PRIME_URL"

    HUGO_VERSION = "0.77.0"


Commit and push the netlify.toml file into Github. Now, you are ready to deploy your site with netlify.

Deploy Site

Now, login into netlify. Then, go to Sites tab of your netlify dashboard and click New site form Git button.

A new popup will open. Select Github and authenticate, with your Github account.

After authenticating, it will ask to select your desired repository. Select the repository you are using for your site.

Now, netlify will take you to the deployment page. Select the branch you want to deploy. Netlify should automatically populate the required fields from the netlify.toml file you created earlier in this post. When you are satisfied with the configurations, press the Deploy button.

Now, netlify will start publishing your site immediately. Wait for the publishing process to complete. Once, the site has been published, you can browse your site at the URL automatically generated by netlify. The auto-generated URL has been pointed out by a red rectangle in the screenshot below.

Customize URL

You can easily customize the URL of your site with just few clicks as shown below.

  1. Click the Domain Setting button under Site Overview tab.
  1. Now, you can either add your own domain by clicking on Add custom domain button or you can just use <your custom prefix> domain. Here, we are going with the later. Click the options dropdown and select Edit site name.
  1. Then, give your site whatever name you want.
  1. Once you have saved the new name, you will see the URL of your site has been updated instantly. Now, you can browse your site at the new URL.