When enabling the .GitInfo
feature it works brilliant, except if there is an Umlaut (ä, ö, ü) in the folder name. In my case removing the ü from the folder name and replacing it with ue worked like a charm.
Unfortunately I can’t share the source code, but a minimal working example can easily be constructed (I’m happy to do so if requested).
The error is visible in the page variable .Page.Lastmod
or in the sitemap.
What does “fail” mean? An error with hugo stopping to build? An issue in your sitemap? Some weird encoding? A message that a file can’t be found?
No, it just doesn’t provide a date (either in sitemap) or on the page. This results in dates like 01.01.0001
There is a very old issue open in Github about this (not GitInfo, but filenames in Hugo and I think this is probably connected). I’ll add a link to this thread so it gets some renewed attention
In general I stopped using umlauts in URLs because some browsers tend to encode them in the URL when they load and it looks ugly. Windows can make people forget about filenames.
I can reproduce the problem on Linux (Ubuntu). You have a couple of options:
Option 1: Fallback
config.toml
enableGitInfo = true
[frontmatter]
lastMod = [":git", ":fileModTime", "lastmod", "date", "publishDate"]
With this configuration, .Page.Lastmod
will try to get the Git timestamp first. If that fails, it will try to read the file modification timestamp from the OS. If that fails it will look for lastmod
in the page’s front matter, etc.
Option 2: Reconfigure Git
I do not understand what side effects this might have, particularly if you are sharing the repository with others, so do some research before making this change.
From the root of your project:
git config core.quotePath false
Note that is not a global change to your Git configuration; the configuration is specific to this project.
My testing:
- Add+commit a file named “umlaüt.md”
- Test results:
.Page.Lastmod
returns the file modification date from the OS (see Option 1)
- Reconfigure the local repository as shown above
- Test results:
.Page.Lastmod
returns the commit timestamp
Notice that I didn’t have to amend the commit to achieve the desired results.
See https://github.com/gohugoio/hugo/issues/9810
This is a local setting that is not shared inside the repository. It quotes the path internally, so the OS does not mis-understand certain special characters as word-boundaries (and thus for instance the filename ends at the special character for the OS).
Long story short: no side effects at all and a very good tip. Should be in the docs for non-english OSses.