Hugo site static resources not loading after adding SSL certificate with Nginx

After freshly installing certbot and forcing HTTPS redirect, my CSS and JS no longer loads, even though it is accessible via direct URL.

I’m not sure why, I’ve updated the links to the CSS and JS files, and set my config.toml to include the https prefix.


server {
        root /var/www/ghm-landing-page/public/;

        index index.html index.htm index.nginx-debian.html;


        location / {
                # First attempt to serve request as file, then
                # as directory, then fall back to displaying a 404.
                try_files $uri $uri/ =404;

    listen [::]:443 ssl ipv6only=on; # managed by Certbot
    listen 443 ssl; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot


server {
    if ($host = {
        return 301 https://$host$request_uri;
    } # managed by Certbot

        listen 80 default_server;
        listen [::]:80 default_server;

    return 404; # managed by Certbot


# Site settings
baseurl = ""
languageCode = "en-us"
title = "Greenhouse Marketplace"
theme = "hugo-highlights-theme"

Your site seems to have some server configuration stuff going on:

In order to assist with the Hugo part of your issue we need the other parts to be working correctly. We are unable to provide support for nginx or certbot. :slight_smile:

I wonder if your certificate is for and not

Other than that without www it now shows up without errors and www leads to a 404 error.

@davidsneighbour is correct.
The issue is not related to Hugo.
It has 2 issues that would need to be resolved:

  1. Certificate was registered with only the root domain name (without www). If you want to host the www. sub-domain, you need to purchase a certificate with all the sub-domains or buy a wild card certificate.
  2. Make sure that the www sub-domain re-directs to the root domain (or vice-versa).
    You can go through this article and hopefully that should help you understand the things better.