Using the "readfile" shortcode - where to store included .md so it is not processed by Hugo? #2198
Replies: 2 comments 2 replies
-
|
Hi, I use a headless directory to store such snippets.
Create a content/headless directory, and place an index.md file in it that
has headless = true in its frontmatter.
…On Thu, Mar 6, 2025 at 1:40 PM James Hurrell ***@***.***> wrote:
I would like to use the readfile shortcode to include some markdown that
is stored in another .md file. My structure is like this:
- folder1
- _index.md
- file.md
- file_to_include.md
- folder2
- index.md
- folder3
- index.md
I am using the readfile shortcode in the folder1/_index.md file to pull
in file_to_include.md, like this:
{{% readfile "file_to_include.md" %}}
The short code works great and my content is included exactly how I want
it, BUT Hugo processes the file_to_include.md file and tries to add it to
the left hand TOC. Since the file_to_include.md file does not contain any
frontmatter, only the markdown I want to use in the other page, it just
creates an empty space in the TOC, like this:
image.png (view on web)
<https://github.com/user-attachments/assets/6ff3cdd6-1f94-41ad-9bec-2ca7b5905e78>
I know that I can get around this by using folder1/index.md instead of
folder1/_index.md since this would create a leaf bundle and ignores
everything else in the folder, but this is not what I want.
So, does anyone have any ideas about where I can store the included
markdown so that Hugo does not process it? I have tried using draft: true
and adding that as the only thing in the frontmatter of file_to_include.md
but it just outputs this front matter in _index.md.
I suspect there is an easy answer but I am missing something here!
thanks
—
Reply to this email directly, view it on GitHub
<#2198>, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AA6AU3JUIAQFKX6DQ56JPID2TA62PAVCNFSM6AAAAABYOS4VNKVHI2DSMVQWIX3LMV43ERDJONRXK43TNFXW4OZYGA2DMNRUGE>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
hurrellit
-
|
Another option is using a hidden directory (name starting with a dot). |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I would like to use the
readfileshortcode to include some markdown that is stored in another.mdfile. My structure is like this:I am using the
readfileshortcode in thefolder1/_index.mdfile to pull infile_to_include.md, like this:The short code works great and my content is included exactly how I want it, BUT Hugo processes the
file_to_include.mdfile and tries to add it to the left hand TOC. Since thefile_to_include.mdfile does not contain any frontmatter, only the markdown I want to use in the other page, it just creates an empty space in the TOC, like this:I know that I can get around this by using
folder1/index.mdinstead offolder1/_index.mdsince this would create a leaf bundle and ignores everything else in the folder, but this is not what I want.So, does anyone have any ideas about where I can store the included markdown so that Hugo does not process it? I have tried using
draft: trueand adding that as the only thing in the frontmatter offile_to_include.mdbut it just outputs this front matter in_index.md.I suspect there is an easy answer but I am missing something here!
thanks
Beta Was this translation helpful? Give feedback.
All reactions