Error Message When Using Link Tag

Hi.

I use collections to separate my project’s posts according to their relation. The collections are placed into a specific folder defined in the _config file with collections_dir variable.

Here is the portion from _config file that configures my collections:

collections_dir: my_collections
collections:
  - topic-1
  - topic-2

Following this configuration, my project’s collection structure is set as follows:

.
├── my_collections:
│     └── _drafts
│     └── _posts
│     └── _topic-1
│            └── introduction.md
│     └── _topic-2
│            └── tool-x-usage.md
...

In a post inside _topic-1 I have a link to another post inside _tips. I used {% link %} tag to set the link as is shown in the example bellow:

my_collections/_topic-1/introduction.md

---
layout: post
---

A [link] ({% link /my_collections/_topic-2/tool-x-usage.md %})

When I run bundle exec jekyll build I get an error message as follows:

Liquid Exception: Could not find document '/my_collections_topic-2/tool-x-usage.md' in tag 'link'. Make sure the document exists and the path is correct. in C:/Users/fern/Documents/jekyll/test/my_collections/_topic-2/tool-x-usage.md

If I comment out the collection_dir variable, the linking works perfectly, for some reason.

I would like to both keep my personalized collection_dir and still be able to use the {% link %} tag. Is that possible? What am I missing?

Try passing the relative_path without /my_collections/:

A [link]({% link _topic-2/tool-x-usage.md %})
1 Like

Hi.

Thanks for the answer. In addition to the suggested modification, I had to modify the collections configuration to include the output: true in the collection metadata.

collections_dir: my_collections
collections:
  topic-1:
    output: true
  topic-2:
    output: true