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 http://denick.org/... So something was not yet right.

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

baseurl = "http://denick.org"

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

baseurl = "//denick.org"

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