HUGO

Data templates & data/subfolders

If possible I’d like to use a shortcode to display a list of files that live across subfolders of /data/features/ – can this be done?

eg /data/features/featureA, /data/features/featureB

The below does not work unless all toml files are in /features/ with no sub folder.:

{{ range $.Site.Data.features }}

originally I had just kept all features in the /features/ folder, but I could not figure out how to grab one and display it by itself because $Site.Data.Features.FeatureName requires a folder name won’t let me just select the toml filename. So now I’m using this:

{{ range (index .Site.Data.features $dataFolderName) }}

Hi @lbliii, if you know how the subfolder structure of your data/features folder looks like you can use merge.

{{ range (merge $.Site.Data.features.featuresA $.Site.Data.features.featuresB) }}

However, you will need to understand, that this overwrites keys of the same name in featuresA with those in featuresB. “There can only be one.”

originally I had just kept all features in the /features/ folder, but I could not figure out how to grab one and display it by itself because $Site.Data.Features.FeatureName requires a folder name won’t let me just select the toml filename.

If there is a file data/features/featureA.toml it should be available as $.Site.Data.features.featuresA. Maybe you post a sample of your folder contents - it might be an issue with keynames in the toml file.