I am finally getting an understanding of Hugo modules. The following is a loosely collection of questions that came up while trying to get the full picture from the documentation (I am trying to rewrite the documentation to be more friendly to non-Go-developers in the end):
- A folder declared in the config option
a) downloaded when adding the module but not available to Hugo or
b) not downloaded when Hugo loads the module?
- Is the config.toml of a module merged into the local configuration or the other way around?
- What happens if the module config.toml declares the following section:
Does this override the local config, is merged (adding the items in
[outputs] home = [ "HTML", "RSS", "Algolia", "REDIR", "HEADERS" ]
homeinto the local
homeslices or is it ignored if a local config option for
homeexists? In my specific case I created a module that adds Netlify headers as a content type to a website. When adding these lines above to the root-config, Hugo does not know YET the redir and headers output format. See this issue.
- “When you add a mount, the default mount for the concerned target root is ignored: be sure to explicitly add it.” - what does that mean?
- Based on my experiments I assume that a module, whose
mountconfiguration does NOT have an explicit target set will be mounted into
themes. Is that right?
- Some posts in the Hugo-Discourse say, that the title in
hugo mod init titlewhen you make your repository/theme/component a module is more or less arbitrary. In my experience if the module lives in Github under davidsneighbour/some-repo-name and I init it as
blafaselthen it leads to notices when updating the module, that the module declares itself as github.com/davidsneighbour/some-repo-name but is mounted as
blafasel(or the other way around). This seems to be just a notice, but will this discrepancy lead to issues further down the road? Wouldn’t it be better to init all modules with a name that has the URL to the repo without the protocoll in the beginning?
- Testing local changes >
replace github.com/bep/hugotestmods/mypartials => /Users/bep/hugotestmods/mypartials- this somehow breaks my live site. I assume this is a change that I should do only locally and not commit to the repository. Is there any way to permanently add this change to my setup without breaking all implementing sites?
- Vendoring: If I have a root module, that adds a theme module that itself uses another module and run
hugo mod vendorin the root module, will this vendor ALL modules or only the next level?
And lastly a tip:
If you have a module, that is a private repository on Github, you will experience issues when you add the repo with an URL as path to the module. Hugo can’t download the module in that case. You can fix that by adding the following lines to your
[url "ssh://firstname.lastname@example.org/"] insteadOf = https://github.com/
This will force
git to access the repository via SSH link even if it is set up via HTTPS. Make sure to have set up authentication via SSH key.
That’s all for now. Sorry for the amount of questions, mods feel free to send this post to annihilation if it’s unfitting.