Iβm very new at Hugo, so I spent some time reading the documentation, prior opening this thread.
I have a very specific website design, with what I call projects. Currently I have /docs and /k3s-cluster projects in my repository, both using the same hextra theme. Basically, the website module I created stores the common elements of each project, allowing me to avoid settings and related code duplication. Due to the unique nature of each project, I cannot merge everything into a single directory. For example, the menu related settings are specific to each project.
This is how I implemented the website module:
Create /go.mod and /hugo.yaml at repository root, as well the other theme common elements, like i18n and layouts.
Into /docs/hugo.yaml configuration, insert the module imports:
Run hugo --gc --minify -s ./docs from repository root, to validate the site is created properly, which will also update /docs/go.mod and /docs/go.sum with correct module versions.
The reason I started this thread is because prior creating the website module, the hextra theme was functioning properly, while preserving the duplicated code in each project directory. Now, certain theme elements are not rendered correctly, which makes me believe I missed something into my website module configuration.
Please see PR sample to replicate the issues locally, if desired. Switch to feature/tutorials branch, start the server and visit the Tutorials page to notice two broken shortcodes, out of seven used:
cd docs
hugo server --buildDrafts --disableFastRender --logLevel debug
For reference, I created also an issue into theme repository.
Is the website module configuration located at root level combined with the /docs theme configuration, or do I have to explicitly define a combination of both, with --config ../hugo.yaml,./hugo.yaml?
Itβs similar, assume the root level is shareable module, then just move the common folder to root level, and replace all relative common moduleβs path, please tweak the replace directive on docs/go.mod.
Create files and test it locally, itβs just an example with only 5 files.
This is for my learning experience, I believe your proposed solution to create a common module is a much cleaner solution, where all related files are grouped inside a directory.
@razon, the site works partially, if you omit the --config switch. Thank you for cloning the repo, it will be easy to test on your side. I understand what you are saying, if /global/hugo.yaml would not load, you would not be able to print the blog.list.displayTags value on frontpage.
As a side note, the theme developer mentioned into the issue I opened that I need to pass the --config switch, which is clearly not the case. I was wondering if you can take few minutes of your busy time and determine the root cause of the problem.
Some configuration will not be merged from modules/themes into site, in this case, you need to set markup._merge as deep (or shallow, I didnβt test).
@razon, thank you for the useful information, it fixes the problem. Both _merge types you mentioned work. Iβm going to use shallow, to avoid any possible merging conflicts.