How is the Apache .htaccess mysteriously generated?


I am new enough to Hugo (and love it!), and despite multiple researches, I could not understand how the .htaccess file is being generated in the public/ directory when I generate the site with the hugo command.

This .htaccess does not embed what I need, so I would like to take control over the generation of this file.

I have looked for the htaccess and apache keywords in my whole project, but no occurrences are found.

I am using a theme (“agico”), which uses modules from but checking each of them, I don’t think any of them is in charge of generating the .htaccess file.

So my questions are:

  1. Do you know what is generating the file?
  2. Do you know how to debug Hugo to identify which piece is generating this file?

Many thanks in advance!
Best regards

It seems that the repo contains an .htaccesshugo-modules/gzip-caching/static/.htaccess at master · gethugothemes/hugo-modules · GitHub
You can perhaps disable or overwrite it with another .htaccess (put it in static for example), but I haven’t looked at the gethugothemes and I don’t know if the original is useful :thinking:

1 Like

You can disable all transitive imports for a given theme import, but that’s probably not working in this case. One “hacky” way of disabling a module is putting a replace statement ala the below in your `go.mod``file.

replace =>
1 Like

Thank you so much!! You are absolutely right.
May I ask you what has been your method to locate it? Eager to learn!

Many thanks @bep, it helps me better understand how modules work, and it will also help me for future debugging.

When I need it for simple needs I place the .htaccess in the static folder.

1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.