Include content from another folder?

Hi all,
I wanted to know if there was a way of including content from another folder into my Hugo build. I have site1 and site2 but they will share a lot of the HTML, I managed to include my Scss from another file and both sites share styles but have not found a way to include content from one site to another.

So if I would have a file called about.html with a {{ .Title }} inside then allow both sites to include it making the title change depending on the site you’re on.

I take it partials only work in the folder they are in right?

Thanks in advance for any help/advice.

In site1, mount the content directory (or a specific subdirectory) from site2:

[[module.mounts]]  # This is the default mount
source = 'content'
target = 'content'

[[module.mounts]]
source = '../site2/content'  # The path can be relative or absolute
target = 'content'

Don’t forget to include the default mount.

https://gohugo.io/hugo-modules/configuration/#module-config-mounts

Thanks @jmooring for the reply and help, but I was wondering if I can a global partials folder that is share between sites. From what I understand partials are not part of the modules system.

This is incorrect.

You can do this:

[[module.mounts]]  # This is the default mount
source = 'layouts'
target = 'layouts'

[[module.mounts]]
source = '../site2/layouts/partials'  # The path can be relative or absolute
target = 'layouts/partials'
2 Likes

Many thanks @jmooring I’ll give it a try )

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