Sitemap.xml created with wrong permissions

This has just started recently (could be with v0.152.2?) but I can build by site with Hugo and it builds fine. Any time after that, it refuses to build with the error:

Error: error building site: render: failed to render pages: open /path/to/DavidgsWeb/public/sitemap.xml: permission denied

And indeed,

-r--r--r--@ 1 davidgs staff 835 Dec 10 12:44 sitemap.xml

DavidgsWeb % rm public/sitemap.xml 
override r--r--r-- davidgs/staff for public/sitemap.xml? y
davidgs@DavidGS DavidgsWeb % hugo                 
Start building sites … 
hugo v0.152.2+extended+withdeploy darwin/arm64 BuildDate=2025-10-24T15:31:49Z VendorInfo=brew


           │ EN  │ DE  │ NL  │ ES  │ FR  
───────────┼─────┼─────┼─────┼─────┼─────
 Pages     │ 300 │ 280 │ 274 │ 280 │ 280 
 Paginator │  15 │  15 │  15 │  15 │  15 
 pages     │     │     │     │     │     
 Non-page  │ 521 │   0 │   0 │   0 │   0 
 files     │     │     │     │     │     
 Static    │ 797 │ 797 │ 797 │ 797 │ 797 
 files     │     │     │     │     │     
 Processed │ 145 │   6 │   0 │   0 │   0 
 images    │     │     │     │     │     
 Aliases   │  78 │  77 │  76 │  77 │  77 
 Cleaned   │   0 │   0 │   0 │   0 │   0 

Total in 3701 ms
DavidgsWeb % hugo
Start building sites … 
hugo v0.152.2+extended+withdeploy darwin/arm64 BuildDate=2025-10-24T15:31:49Z VendorInfo=brew

Total in 891 ms
Error: error building site: render: failed to render pages: open /Users/davidgs/github.com/DavidgsWeb/public/sitemap.xml: permission denied
davidgs@DavidGS DavidgsWeb % 

So whenever Hugo builds the site, it creates the sitemap.xml without write permissions, so subsequent attempts fail.

Has anyone else seen this? Is it peculiar to macOS?

What are the rights on the public folder? I have seen this some times on Linux with robots.txt and adding write rights for all on the public folder or deleting the public folder before running hugo solved it.

I suspect this is related to a change on your build PC. Hugo has “always”

  1. Created directories with 0777 (before umask)
  2. Created files with 0666 (before umask)

The umask reference above refers to the standard setting which may make the Hugo permissions more or less permissive – but it outside of Hugo’s control.

I am also experiencing this on Windows with Hugo v0.152.2

If I delete the public directory, the first time I run hugothe public directory is created,

drwxr-xr-x@  24 davidgs  staff      768 Jan  5 10:28 .

And all the directories have the same permissions. All the files are the same (minus the execute permission). The only file in public that is created without any write permission is sitemap.xml.

I’m not sure what you mean by the “standard setting” for umask.

I’m not a macOS expert, but I believe the presence of the @ symbol in your file and directory permission indicates additional attributes. What are they?

Also, on a new (virgin) MacBook Air, after building a new site in a new directory…

My umask, as expected, is 022, determined by typing umask in the terminal.

I tested with each of these installation methods:

  • Homebrew
  • Downloading the pkg file from the list of release assets
  • Building from source
  • Using hvm

@davidgs Where do we stand with this?

I’m not sure what exactly is going on, still. On my Mac Studio, once I ran xattr -cr on the parent directory, the problem went away. On my work laptop (same macOS version), that fix does not work. I’m wondering if there is something in the corp policies installed that is adding extended attributes to be created by default. For now, I’m either doing all my Hugo work at home on the Studio, or just repeatedly removing the sitemap.xmlevery time.

Have you tested v0.153.0? For that version and later we now build signed and notarised pkg installers.

Use the prebuilt binary, not Homebrew. I have no idea if Homebrew is a factor here, but let’s remove it from the equation for now.

Hello,

I just installed Hugo with the prebuilt binary, version 0.155.2-extended. When I follow the “getting started” with the Ananke site, I have no problem. However, I am trying to use GitHub - hugo-themes/toha: A Hugo theme for personal portfolio , and with this theme I have the same problem of the sitemap.xml being created with read-only permissions. If I change the permissions to rw-rw-rw it works fine, until a page change and then the permissions are resetted to read-only.

I have looked at the issues on Toha but could not find anything that would relate to this, so I am unsure if this is a Hugo or a Toha problem.

I am on Linux Mint 22.3

EDIT: This is likely a toha problem. I made more tests and things are running fine until I set up the toha module, then it starts using the wrong permissions.