I must be dumb - link to markdown file in same directory

My problem, for the life of me I cannot work out how to link to a page in the same directory as the post. I’ve searched and none of the solutions I have found work.

This is directory structure: (is this called a leaf bundle?)

└── test_post2/
    ├── index.md -> Link to open linked_file2.md
    ├── linked_file2.md
    └── img/
        └── image.png

The test post : test_post2 · johndoe

The image link works fine:


But every attempt / variation I’ve tried to link to a markdown file has failed and it seems to be a pretty basic thing that all website need to do, so why am I having problems doing this/ understanding this?

If I use {{< ref "linked_file2.md" >}} hugo reports this error :

ERROR [en] REF_NOT_FOUND: Ref “linked-file2.md”

I’ve worked out that standard markdown linking doesn’t work (can anyone explain why not?):


just reports a 404 error when the link is clicked.

Thanks again, if someone could point me in the right direction, any help is appreciated.

Because linked-file2.md is not a page. It’s just a file. And it can’t be a page because of

It’s not clear what you want here: If linked_file2.md should become a page under posts, you must change your directory structure. If you want to link to the original MD file, you must make sure that it’s copied into the public directory at build time. That happens when you put it in static or assets.

The documentation is not very helpful.

What I am trying to achieve:

The report I am writing is huge, 15 sub documents, 100+ images. Not surprisingly, I want to keep the files relating to the report together in one place.

The idea of trying to manage the document with files and images in a different location does not appeal and is counter intuitive to the way I used to run wordpress where I could put all content related to the post in the same location as the post and simply refer to it with a link.

So I go back to my original question, which the documentation has not helped answer, how do I link to another markdown document and have it correctly rendered as though it were part of the site?

thanks again

Do you want to insert the content of these subdocuments into the parent document, or link to them?

Thanks again,

I want to link to the file and have it open as a rendered web page.

├── posts/
│   ├── post-1/
│   │   ├── _index.md    <-- branch bundle
│   │   ├── a.jpg
│   │   ├── sub-doc-1.md
│   │   └── sub-doc-2.md
│   └── _index.md
└── _index.md

I’m sorry you find the documentation unhelpful, but I suggest you spend some time reading about the differences between leaf bundles (no descendent pages) and branch bundles.


1 Like

Working, thank you.

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