Serve Json on Azure App Service #

I have been setting up an internal work site based on Hugo in Azure App Service (it’s in App Service so we can protect it easily with Azure AD).

Using the Academic theme, I noticed the local search wasn’t working. This relies on accessing a JSON version of the site content, and a quick look in DevTools showed index.json was being served as a 404 error.

The fix, via StackOverflow, is to create a Web.config file in the root of the site. Specifically, for Hugo, add a file /static/Web.config with the following content:

<?xml version="1.0"?>
            <remove fileExtension=".json"/>
            <mimeMap fileExtension=".json" mimeType="application/json" />

As an aside it’s worth noting that with this combination of technologies (plus Azure DevOps to do the CI/CD build) I could set up a good-looking internal-only comms site in under an hour. With such a light payload it could easily sit on an existing App Service Plan, so the marginal resource cost is zero.

Julian Elve
Proactive application of technology to business

My interests include technology, personal knowledge management, social change