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

https://www.greenhousemarketplace.com

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.

sites-enabled/ghm-landing-page

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

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

        server_name greenhousemarketplace.com;

        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/greenhousemarketplace.com/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/greenhousemarketplace.com/privkey.pem; # 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 = greenhousemarketplace.com) {
        return 301 https://$host$request_uri;
    } # managed by Certbot


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

        server_name greenhousemarketplace.com;
    return 404; # managed by Certbot

config.toml

# Site settings
baseurl = "https://www.greenhousemarketplace.com/"
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 greenhousemarketplace.com and not www.greenhousemarketplace.com.

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.