Hugo deploy doesn't upload 404.html correctly (Azure Blob storage)

I use the hugo deploy command to upload to an Azure Blob. That works fine; there are no problems and everything uploads.

But I have an issue with the 404.html page. When I navigate to a page that doesn’t exist in the Blob, this shows in the browser:

At first I thought, an issue in my configuration. So I double-checked everything and searched through the official documentation and various blog posts. But I didn’t find a mistake.

So I opened a MSDN support question. That discussion didn’t help; everything suggested there I have configured properly.

Then I thought, why not upload the 404.html through the web browser. To my surprise, that works fine:

My question: how can I make hugo deploy upload the 404.html page properly?


Additional details

  • The problem does not happen when I upload the exact same website with the Azure CLI. This means:

    • The rendered 404.html code is okay.
    • My Azure blob is configured properly.
    • The authentication happens correctly.
    • There is no issue on Azure’s end.
  • Furthermore:

    • Hugo uploads every other file properly (HTML, JavaScript, XML, CSS). There are no files missing.
    • The 404 page is the only HTML page that “shows up funny”. Every other file shows at it should. The JavaScript and CSS files are also readable without strange characters.
  • There are no errors when hugo deploy runs:

hugo deploy --maxDeletes -1

Deploying to target "____" (azblob://$web)
Identified 7 file(s) to upload, totaling 9.1 kB, and 0 file(s) to delete.
Success!
  • This is my deployment configuration:
[deployment]
    [[deployment.targets]]
        name = "______"
        URL = "azblob://$web"

    [[deployment.matchers]]
        pattern = "^.+\\.(js|css|svg)$"
        cacheControl = "max-age=31536000, no-transform, public"
        gzip = true
    [[deployment.matchers]]
        pattern = "^.+\\.(png|jpg)$"
        cacheControl = "max-age=31536000, no-transform, public"
        gzip = false
    [[deployment.matchers]]
        pattern = "^.+\\.(html|xml|json)$"
        gzip = true
  • I use Hugo 0.64 extended.

I made two Azure blob storage accounts and uploaded with the Azure CLI to one, and did a hugo deploy to the other.

This way I could compare. And that made it possible to figure out that hugo deploy gzips the 404.html page, while the Azure CLI upload does not.

That turns out to be the solution! :smile:

Hugo deploy uploads correctly to Azure by adding this to the TOML configuration file:

[[deployment.matchers]]
    pattern = "^.*404\\.html$"
    gzip = false

Problem solved. :slight_smile:

Edit: This looks to be an Azure Blob storage limitation. There’s a feature request here to allow gzip encoding for the 404 document.