Configuring HUGO for https

This website is now available via https. Here is how I configured Hugo to be compatible.

When I opened the site over https, the stylesheet was not loaded because it was defined in the source to be located at So something was not yet right.

Let’s take a look at Hugo’s config.toml:

baseurl = ""

It was forced at http! What happens when we change it to be protocol agnostic?:

baseurl = "//"

Regenerate the site (run hugo) and indeed: the website is now protocol agnostic, both http and https work. The user is however forced to the https pages by this rewrite rule in .htaccess:

RewriteEngine On
RewriteCond %{HTTP:X-Forwarded-Proto} !http
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

That works :)

Written by Denick Murray