I get the following error when trying to build a hugo project -
file name too long
I have set the configuration so that the title is part of the url (and by extension the filename when files generated via build).
Now, I’m not sure whether hugo has a character limit for filenames. Or is it a system one.
I suspect it might not even be the length of the title. Some of the titles have periods for figures (e.g. 1.2 million). Does that throw the build process off? Maybe because period is a reserved character for url paths?
Any help much appreciated.
Share your code, and folks may be able to help you
Just wanted to know if there was a character limit for titles in Hugo. And if so, how to handle it (e.g. can we just tell hugo to cut if off at the limit rather than give an error)?
Which part of the code would you like? In the config.toml, the permalinks are set in the following way
posts = "/:year/:month/:day/:title"
And here is an example of error and title that is too long -
public/2019/05/07/study-finds-global-action-needed-to-ensure-acceptable-climate-futures-researchers-studied-population-growth-the-cost-of-carbon-free-technologies-and-the-climates-sensitivity-to-greenhouse-gas-emissionsand-examined-52-million-future-samples-from-these-uncertainties/index.html: file name too long
every OS has a limit for path length.
Choose a shorter title and pack the long text in the description
You can also have a long title and put the short variant in the
Thanks @bep! That actually seems quite sensible! I will do just that.
Could be a nice feature for hugo to programatically generate a short version of the title as slug but that may perhaps be too much to ask for. I’m sure you have a lot on your plate already.
Thanks for all your hard work on hugo!
Yes, maybe, but we have no good way of knowing the upper limit, so we would probably end up setting it too low for most people.
You are right. It could vary and adding this may make it unnecessarily bloated. It can, in any case, be easily implemented outside of hugo.
Just an FYI, for those interested, the limit on Ubuntu seems to be 255 characters