I am attempting to automate a HUGO Static Site Generation system.
- Repo A is content that would normally be in the
/Content
directory.
Repo A will be changed often and consists of just .md files. - Repo B is a Hugo Site complete with a Theme directory.
Repo B never changes often. - Repo C is to be a combination of Repo A and B and compiled when there is a new push to Repo A (the content).
I suspect GitHub Action can do this on some sort of push event of repo A.
Where do I begin researching how this would be performed?
Is there a better solution for maintaining the HUGO site and Hugo content in separate Repos?
FYI: This is a HUGO Project, which is a static site generator.
CodePudding user response:
As described in "Using git submodule for Hugo themes", you should not need 3 repositories, but 2.
One for content, which includes in the themes/
folder your theme submodule repository.
You can then add a GitHub Action like jakejarvis/hugo-build-action
to build the site on each git push
.
CodePudding user response:
You can use Hugo Modules to achieve what you have in mind. My setup is similar to yours--separate repo for content, the site itself, and I'm pulling themes as a Hugo module too.
Here's how to do it
In your module.toml
file (if you are using the /config/
directory setup.
[[imports]]
path = "gitlab.com/youronlyone/content"
# BGN: /yuki/ content
[[imports.mounts]]
source = "yuki/en-ph"
target = "content"
lang = "en-ph"
[[imports.mounts]]
source = "yuki/ja"
target = "content"
lang = "ja"
[[imports.mounts]]
source = "yuki/ko"
target = "content"
lang = "ko"
# END: /yuki/ content
# BGN: /snoworld/ content
[[imports.mounts]]
source = "snoworld/en-ph"
target = "content"
lang = "en-ph"
[[imports.mounts]]
source = "snoworld/ja"
target = "content"
lang = "ja"
[[imports.mounts]]
source = "snoworld/ko"
target = "content"
lang = "ko"
# END: /snoworld/ content
# BGN: /techmagus/ content
[[imports.mounts]]
source = "techmagus/en-ph"
target = "content"
lang = "en-ph"
[[imports.mounts]]
source = "techmagus/ja"
target = "content"
lang = "ja"
[[imports.mounts]]
source = "techmagus/ko"
target = "content"
lang = "ko"
# END: /techmagus/ content
# still needed
[[mounts]]
source = "content/en-ph"
target = "content"
lang = "en-ph" # when in multihost / multilang mode
[[mounts]]
source = "content/ja"
target = "content"
lang = "ja" # when in multihost / multilang mode
[[mounts]]
source = "content/ko"
target = "content"
lang = "ko" # when in multihost / multilang mode
If you are using a single config
file, just add module.
prefix like so:
[module]
[[module.imports]]
path = "gitlab.com/youronlyone/content"
# BGN: /yuki/ content
[[module.imports.mounts]]
source = "yuki/en-ph"
target = "content"
lang = "en-ph"
[[module.imports.mounts]]
source = "yuki/ja"
target = "content"
lang = "ja"
[[module.imports.mounts]]
source = "yuki/ko"
target = "content"
lang = "ko"
# END: /yuki/ content
# still needed
[[module.mounts]]
source = "content/en-ph"
target = "content"
lang = "en-ph" # when in multihost / multilang mode
As you can see in the above code, it is possible to support a multilingual site.
It is also possible to only pull a specific content, like so: (below is code for /config/module.toml
setup)
[[imports.mounts]]
source = "love/en-ph"
target = "content"
lang = "en-ph"
includeFiles = ["**/20160703-the-choice-2016.md"]
[[imports.mounts]]
source = "love/ja"
target = "content"
lang = "ja"
includeFiles = ["**/20160703-the-choice-2016.md"]
[[imports.mounts]]
source = "love/ko"
target = "content"
lang = "ko"
includeFiles = ["**/20160703-the-choice-2016.md"]
Or to pull from multiple repos.
Hugo modules is not only for content, it works for i18n, archetypes, data, static, etc. See Module Config: mounts.
As long you've setup Hugo Modules correctly, the GH actions for Hugo will work since it is Hugo that pulls those separate repos during build time (not the GH action script).