Hugo learn theme and attachements: failed to read directory

Hello there!

I’m using the hugo learn theme for my project which is separated in a folder hugo-framework and a folder hugo-content. I have separated the content folder to the hugo-content folder and in my config.toml I have added the following code:

[module]
[[module.mounts]]
source = "../hugo-content"
target = "content"

When not using attachements, hugo builds the project without issues. But when I add the attachement shortcode to (for example) MyMarkdown.md and also add a MyMarkdown.files folder, where MyMarkdown.md exists (it’s all in the hugo-content folder) I get the following error:

Error: Error building site: “C:\Users\me_Hugo1\hugo-content\folder1\MyMarkdown.md:13:1”: failed to render shortcode “attachments”: failed to process shortcode: “C:\Users\me_Hugo1\hugo-framework\themes\hugo-theme-learn\layouts\shortcodes\attachments.html:14:11”: execute of template failed: template: shortcodes/attachments.html:14:11: executing “shortcodes/attachments.html” at <readDir (printf “./content/%s%s” $fileDir ($.Scratch.Get “filesName”))>: error calling readDir: failed to read directory “./content/folder1/km.files”: open C:\Users\me_Hugo1\hugo-framework\content\folder1\MyMarkdown.files: The System cannot find the specified path.

This seems correct to me because I don’t use the content folder of the framework, so maybe the line in the attachements.html is wrong? The code is:
{{ range (readDir (printf “./content/%s%s” .Page.File.Dir ($.Scratch.Get “filesName”)) ) }}

I tried to change the string it to “…/hugo-content/%s%s” but it didn’t work either. So I’m not sure, how to fix my problem.

I’m thankful for any help!
Best regards,
Rafael

AFAIK, readDir and readFile only works for file/dir that is relative to your project directory.

../hugo-content is outside the project directory.

also both functions doesnt work with Hugo Virtual Union Filesystem. Thats why readDir cannot read mounted target under content/folder1/MyMarkdown.files.