HUGO

One repository for content, another for site source (hugo on netlify)

Hi, is it possible to have one repository in which the Hugo site source is held (without the content, but does include the templates) and another where it’s only what would be under the template folder?

I would want to try to host something like this on Netlify.

I did think of using Git Submodules but they need to be updated on each build, so either an automatic commit to refresh the submodule or (on netlify) running a command to update the submodules.

But then builds don’t automatically launch after something is put into the content repository.

Maybe, perhaps, there is a way to mirror the two repositories somehow? and is this possible at all? (considering I want to open source the content, but not the site source)

(Maybe a better question for the netlify forum, but I wanted to ask here too)

Check out modules. The answer is yes.

@gethugothemes, how would this help?

Netlify has a feature called Build Hooks. You can force a re-deploy by sending a POST to an URL. I would create a Github action on the content repository that calls to the Netlify build hook of the “main repository” (the one that loads the content and others as module) on push events to the content repo.

Nice. Could you use the Build Hook to refresh a git submodule and then rebuild the site, or do you need to pull in the content using a Hugo module?

I would write a deploy script that is run instead of the hugo call.

#!/bin/bash

hugo mod get -u ./...
hugo --more --parameters

Instead of the mod get -u you could run your submodule update call. There seems to be no way to force an “empty cache and redeploy”, that’s only possible manually via the website.

I suspect you can avoid a build hook by making the “content repo” the Hugo project you build from. This would then contain content only, but would import other repos (theme etc.).

This way you trigger builds

  • when the content changes
  • and when the theme changes (which would update the module version in the content repo)