# Linking \_pages Minimal Mistakes, post\_url and link

**URL:** <https://talk.jekyllrb.com/t/linking-pages-minimal-mistakes-post-url-and-link/1811>\
**Category:** Help\
**Created:** [May 19, 2018, 3:14pm UTC](https://talk.jekyllrb.com/t/linking-pages-minimal-mistakes-post-url-and-link/1811 "2018-05-19T15:14:03Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![johnlane](https://avatars.discourse-cdn.com/v4/letter/j/eb8c5e/32.png) [@johnlane](https://talk.jekyllrb.com/u/johnlane)\
**Post date:** [May 19, 2018, 3:14pm UTC](https://talk.jekyllrb.com/t/linking-pages-minimal-mistakes-post-url-and-link/1811/1 "2018-05-19T15:14:03Z")

</div>

I’ve been using `link` for some time to cross reference pages in the collections of my site which is based on the Minimal Mistakes theme.

For collections, these work fine:

```auto
[document]: {% link _collection/document.md %}
[post]: {% _posts/2018-0501-post.md %}

```

where `_collection` is a collection directory beneath `collections` (as defined by `collections_dir` in `_config.yml`). It works for `_posts`, and anything else I have there.

Now I cannot get `post_url` to work. If I try

```auto
[post]: {% post_url 2018-0501-post.md }

```

then the site does not build because the file cannot be found. I guess that is because the `post_url` code doesn’t know about the movement of posts into `collections_dir` ?

**Should `post_url` work with posts inside `collections_dir` ?**

I started looking at this because I wanted to link a page (i.e. a document in `_pages`, which is outside the `collections_dir`) but I could not work out how to do that with `link`.

**Is it possible to `link` to a page ?**

---

<div class="post-metadata">

**Author:** ![mmistakes](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/mmistakes/32/2169_2.png) [@mmistakes](https://talk.jekyllrb.com/u/mmistakes)\
**Post date:** [May 19, 2018, 4:29pm UTC](https://talk.jekyllrb.com/t/linking-pages-minimal-mistakes-post-url-and-link/1811/2 "2018-05-19T16:29:42Z")

</div>

Remove the file extension and it should work. It’s used slightly different from `{% link %}` which you provide the full file name.

```auto
[post]: {% post_url 2018-05-01-post %}

```

> **[Liquid](https://jekyllrb.com/docs/templates/#linking-to-posts)**
>
> Jekyll uses the Liquid templating language to process templates.

---

<div class="post-metadata">

**Author:** ![johnlane](https://avatars.discourse-cdn.com/v4/letter/j/eb8c5e/32.png) [@johnlane](https://talk.jekyllrb.com/u/johnlane)\
**Post date:** [May 19, 2018, 4:35pm UTC](https://talk.jekyllrb.com/t/linking-pages-minimal-mistakes-post-url-and-link/1811/3 "2018-05-19T16:35:22Z")

</div>

Ah, yes. That does indeed work like that. Now I just need to work out how to link to a page (that is outside `collections_dir`). Is that possible (other than linking to the generated file’s location) ?

---

<div class="post-metadata">

**Author:** ![mmistakes](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/mmistakes/32/2169_2.png) [@mmistakes](https://talk.jekyllrb.com/u/mmistakes)\
**Post date:** [May 19, 2018, 5:21pm UTC](https://talk.jekyllrb.com/t/linking-pages-minimal-mistakes-post-url-and-link/1811/4 "2018-05-19T17:21:55Z")

</div>

Check that link above, it has suggestions on determining the correct path of a file when using the link tag.

---

<div class="post-metadata">

**Author:** ![johnlane](https://avatars.discourse-cdn.com/v4/letter/j/eb8c5e/32.png) [@johnlane](https://talk.jekyllrb.com/u/johnlane)\
**Post date:** [May 19, 2018, 7:02pm UTC](https://talk.jekyllrb.com/t/linking-pages-minimal-mistakes-post-url-and-link/1811/5 "2018-05-19T19:02:15Z")

</div>

Ok, so I put `{{ page.path }}` on a page that I wanted to link to and viewing that page revealed its path as `_pages/document.md`

But that’s what I thought it was. That’s what I thought I’d tried this morning, and what didn’t work (since deleted so cannot compare). I try it now and, guess what, it works:

```auto
[document]({% link _pages/document.md %}) 

```

So I am somewhat stumped over what I did wrong before, because it works. Appreciate the help but feel a bit green. Thanks for the pointer 🙂

---

<div class="post-metadata">

**Author:** ![johnlane](https://avatars.discourse-cdn.com/v4/letter/j/eb8c5e/32.png) [@johnlane](https://talk.jekyllrb.com/u/johnlane)\
**Post date:** [May 20, 2018, 2:02pm UTC](https://talk.jekyllrb.com/t/linking-pages-minimal-mistakes-post-url-and-link/1811/6 "2018-05-20T14:02:41Z")

</div>

Wel’ it turns out not to be so straightforward and that’s why it didn’t work for me previously.

Looking at `{{ page.path }}` illustrates that setting a `permalink` in front matter affects the page path. I understood `page.path` to refer to the acutal path to the page’s source markup file. But that appears not to be the case.

If a page has no frontmatter permalink then `page.path` is the path beneath `_pages` (ie for `_pages/directory/document.md` it returns `directory/document.md` and that successfully works with `link` to reference the page. The rendered page URL is, however, different and follows the permalink set in `config.yml`.

That’s the behaviour I would expect.

If the page has a frontmatter permalink then it affects `page.path`. For example a `permalink: some/random/path` in the frontmatter causes `page.path` to return `some/document.md` which is neither the complete permalink nor the real path of the file. In my configuration, this permalink doesn’t affect the URL of the rendered file which continues to follow the permalink set in `config.yml`.

Furthermore, if the permalink is the same path as the file then the `{{ page.path }}` becomes the file name only.

All of this leaves three possible results for `{{ page.path }}`:

- with permalink different to file location: `some/document.md`
- with permalink same as file location: `document.md`
- without permalink: `directory/document.md`

So **`page.path` is not always the acutal path to the page’s source markup file.**

I don’t understand what’s happening - is it a bug, am I doing something wrong, I don’t know. I could spend ages researching it (more than I have already) which I can’t really afford. I know enough to get what I want to work but there does seem to be something odd going on…

* * *

An afterthought… it’s possible to name files and directories so that there is a conflict between `_pages` and `_collections`, which it would appear that `_pages` wins. However, the requred naming for such a conflict makes this scenario unlikely.
