Is it possible to get static sites to work with both HTTPS and HTTP?

Hi, I would like to know if it possible to get static sites generated by Hugo to work with both HTTPS and HTTP? The main problem is the baseURL, as far as I remember, the menu items use it as a reference to link other pages… the problem is, if HTTP is used in baseURL, the menu items will always point towards the HTTP URLs… even if a users accesses the page via HTTPS.

What I want is that the menu should use HTTPS link in the menu if the user used HTTPS to access the site… same for HTTP pages, HTTP links for HTTP pages :slightly_smiling:

I know a possible workaround, generate the site 2 times using both HTTP and HTTPS version of the baseURL, but it really isn’t the answer to my question :disappointed_relieved:

Is there something else which could address this issue? Thanks in Advance! :smile:

Well, there is some good news. The answer to your question is unequivocally “yes.” The bad news is that the questions you’re asking are really unrelated to Hugo and more about how you set your hosting/service/etc.

If you’re serving over HTTPS, I would just force SSL. Is there any reason why you would want to do both?

If you use Netlify for your hosting (it’ll likely be free), forcing SSL is (literally) just a matter of a single checkbox:

I think you have mis-understood me @rdwatters, what I want to do is, server the pages via both HTTP and HTTPS… not forcing HTTPS only.

The problem is, the reference of a particular protocol in the HTML documents… it is either HTTP or HTTPS. I want the visitors of my site have a choice of using HTTPS if they want… but it is not forced in anyway. The pages load fine in HTTPS, but external content like stylesheets and images are loaded over HTTP because the HTML code references the HTTP URL… Same for the links in the page, they are all HTTP links.

I understand. I’m asking why:)

Have you tried making your baseURL value in your config file protocol relative, similar to the way the value is assigned for localhost? That is, // rather than


Oh Wow! I have never seen that being used before! Now my site works like a charm with both HTTP and HTTPS, thanks a lot! :smiley: