Hugo private theme hosting similar to Jekyll theme gems?

I’m just digging into Hugo and trying to replicate some Jekyll workflows that are necessary for me.

In Jekyll I have a gem based theme which is hosted privately on GemFury, GitHub etc. This means that the actual theme contents aren’t exposed within the site’s repository - there’s no cloning the theme into my site’s repository like in Hugo. The theme is only processed upon build and into the _site (output) directory.

Is there any way I can implement this workflow with Hugo? I don’t want to clone a theme in to the themes directory, because that would expose my theme src. I want to be able to point to my private repository, and then this to be generated into the site on build.

Not at this point.

There is no need to expose your Hugo code, config, theme. Generate and publish public. I do not know if you have other restrictions but that should work.

I ended up half solving this by turning both the theme and site into modules but I have one last problem.

My theme repository on GitHub is a private repo, so I have to set a config option to add my personal access token into the URL:
git config url."https://[USER]:[TOKEN]@github.com".insteadOf "https://github.com"

My problem is that this only works if I set this in my --global git config. It does not work in the --local git config and I get the following error whenever Go/Hugo access the repo:
go get: module github.com/[USER]/[THEMEREPO]: git ls-remote -q origin in /var/folders/26/gqnv01_55p964v8yz39d51fw0000gn/T/hugo_cache/modules/filecache/modules/pkg/mod/cache/vcs/b410fc7b91fbc1121b5f6ec2bb2711c27cd172b4084c213e1430a33cde552597: exit status 128: remote: Repository not found. fatal: repository 'https://github.com/[USER]/[THEMEREPO]/' not found

How can I force Go/Hugo to use the local git config rather than the global? I don’t want to funnel every git connection through my personal access token just so I can use this theme for some of my sites

I solved this by adding a directory replacement mapping to the site’s config, instead of modifying the git url. This points to my locally cloned theme and updates the served site whenever I modify the theme.

module:
     imports:
       path: 'github.com/[USER]/[REPO-NAME]'
     replacements: 'github.com/[USER]/[REPO-NAME] -> ../../[REPO-NAME]/'

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.