Excluding Static Folders (reprise)

(sorry to make new thread - but the old one closed because of the 2 day time out)

This is a follow on to: Excluding Folders in Static

Mainly, I wanted to thank @jmooring for being so helpful.

But also to point at a small thing that I still can’t figure out how to do with the mounts system (as opposed to the old staticDir approach):

The problem is that there is a long list of directories. Only one of them is different between configurations. Using this scheme, I need to repeat that long list in both of the TOML files (note how you repeated static).

I had hoped that I could have the default list in the “default” toml file, and only have the over-ride folder in the “overlay” toml file. (I load a second toml file after the first from the command line when I need both).

This is how it used to work… The default config.toml specified both staticDir and staticDir2, and the overlay only over-wrote staticDir;

Having to repeat isn’t the end of the world. I can also see how going forward, the mounting system allows me to be more strategic in how I use mounts.

Again, thank you for your help. The willingness of the community to help is a really big part of why I love Hugo. Hugo lets me build crazy things like the class workbooks, but it also has the community to save me when I try to do something that is too crazy.

Oh, by the way, you can see last week’s example solution (where this is applied) at: GitHub - CS559-Spring23/Workbook01-Solution: Sample Solution for 2023 Workbook 1 or https://cs559-spring23.github.io/Workbook01-Solution/ - the students don’t know that this was built with Hugo.

Oh… and just for the record…
The file names need to be in the right directory… so I had to do:
excludeFiles = [".git","*/.git","*/*/.git"]

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

** can be used as a super-asterisk to match recursively down all directories

Example:

[[module.mounts]]
source = 'static'
target = 'static'
excludeFiles = '**.git'

Thanks again!

I knew there was a “super asterisk” but it was easier to try the brute force solution. I guess I am acting like a student.

I didn’t understand this requirement. Use a different approach: module imports.

config/
├── cs559/
│   └── config.toml
├── cs800/
│   └── config.toml
└── _default/
    └── config.toml
config/_default/config.toml
[[module.mounts]]
source = 'static'
target = 'static'
excludeFiles = '**/.git'

[[module.mounts]]
source = '../common/common-1'
target = 'static'
excludeFiles = '**/.git'

[[module.mounts]]
source = '../common/common-2'
target = 'static'
excludeFiles = '**/.git'

[[module.mounts]]
source = '../common/common-3'
target = 'static'
excludeFiles = '**/.git'

config/cs559/config.toml
[[module.imports]]
path = '../../common/cs559/'

config/cs800/config.toml
[[module.imports]]
path = '../../common/cs800'

Then in your common directory…

../common/
├── common-1/
│   └── common-1.txt
├── common-2/
│   └── common-2.txt
├── common-3/
│   └── common-3.txt
├── cs559/
│   ├── config.toml
│   └── cs559.txt
└── cs800/
    ├── config.toml
    └── cs800.txt
..common/cs559/config.toml
[[module.mounts]]
source = '.'
target = 'static'
excludeFiles = '**/.git'


..common/cs800/config.toml
[[module.mounts]]
source = '.'
target = 'static'
excludeFiles = '**/.git'

To build your site, use one of the following:

hugo          --> just the common stuff
hugo -e cs559 --> common stuff + cs559
hugo -e cs800 --> common stuff + cs800

Thank you. I am going to have to chew on this a bit. I am not sure I understand how these pieces fit together. I’ll have to read this carefully. There is clearly a gem in here, but I need to work through the details to see how this works and how to adapt it.

One thing I don’t see: I want the overlay to over-ride the default. In your example, there are 2 different overlays. In my goal, there is “default” (which has “for_students”), and “solution” (which replaces “for_students” with a different version).

I need to spend more time to understand what you are recommending, and to learn from it. With each iteration I am learning more… Thank you!