Directory relative links between pages

I am trying to generate links between pages using the method explained in http://learn.getgrav.org/content/linking

None of the methods (directory relative nor absolute) I tried resolve the link correctly and the URL is the unprocessed/unresolved directory entry rather the page’s default route.

For example if I have a page in /pages/02.green/01.grass/default.md I expected to get the url configured as default route when generating links or the slug if no default route given.

But when using:

[Some link](01.grass/default.md) generates /02.green/01.grass/default.md
or
[Some link](01.grass) generates /02.green/01.grass
or
[Some link](/02.green/01.grass) generates /02.green/01.grass

Is there a setting I overlooked which turns on link processing?

First, it’s much better not to use the actual folder directories. This is because if you change the directory or change the ordering, it will break your links. Better to use the route.

So, for your example page in pages/02.green/01.grass/default.md the route to this (as shown in your browser) is: /green/grass. So from some other page the simplest way to reach this page is via:

[Some link](/green/grass)

That’s all there is to it.

Yes, but we have different needs for inter-page linking and were hoping the methods described in http://learn.getgrav.org/content/linking would work.

  1. Using the proposed slug method would still not resolve the link to be rendered with the default route set in the page header:
title: A web page
routes: 
   default: /my/web/1234-page-with-a-very-long-url-which-may-change
  1. Are the methods for directory relative and absolute page linking described in http://learn.getgrav.org/content/linking actually working?

The examples described in the documentation are

[link](../../02.green/01.grass/item.md)
[link](/01.blue/01.sky)
[link](../../02.green/01.grass)
[link](../../02.green)
[link](../../02.green)
  1. I am hoping for a method which can generate the default route of a page based on some form of handle or identifier. It does not matter for us if that is the file name or the slug or even a page id of some form. This all should work in a multi-languag e context were the default routes are different for the languages but still the page’s file name, slug or handler or id would be the same.

Well in my test they are all working fine. Obviously the example below is based on my testing site, but you can get an idea of the various link types:

### Directory relative

* just down [01.item2-1](01.item2-1)
* just up [..](..)
* file link with [../../03.blog/2015-01-11-atom-vs-coda/item.md](../../03.blog/2015-01-11-atom-vs-coda/item.md)
* up more and down more no filename but hash [../../03.blog/focus-and-blur#something](../../03.blog/focus-and-blur#something)
* up and down no filename [../03.assets](../03.assets)
* up more and down more no filename but query + hash [../../03.blog/focus-and-blur?foo=bar#something](../../03.blog/focus-and-blur?foo=bar#something)
* file link [../../03.blog/focus-and-blur/item.md](../../03.blog/focus-and-blur/item.md) {.button}

### Slug relative

* up and down with [../../blog/atom-vs-coda](../../blog/atom-vs-coda)
* up and down with param [../../blog/tag:birds](../../blog/tag:birds)
* up and down with anchor [../smartypants#someanchor](../smartypants#someanchor)
* up and down with query [../smartypants?foo=bar&cat=brown](../smar typants?foo=bar&cat=brown)
* up and down into smartypants [../smartypants](../smartypants)
* up more and down more [../../blog/focus-and-blur](../../blog/focus-and-blur)
* just down [item2-1](item2-1)

<a name="test" class="anchor"></a>
## Absolute

* absolute link: [/blog/focus-and-blur](/blog/focus-and-blur)
* absolute link with param: [/blog/tag:birds](/blog/tag:birds)
* absolute with paths: [/03.blog/2015-01-11-atom-vs-coda/item.md](/03.blog/2015-01-11-atom-vs-coda/item.md)
* absolute with relative: [/08.test/../03.blog/2015-01-11-atom-vs-coda/item.md](/08.test/../03.blog/2015-01-11-atom-vs-coda/item.md)
* absolute link + query: [/blog/focus-and-blur?foo=bar](/blog/focus-and-blur?foo=bar)
* absolute with paths + query: [/03.blog/2015-01-11-atom-vs-coda/item.md?foo=bar](/03.blog/2015-01-11-atom-vs-coda/item.md?foo=bar)

### Hash Links

* relative hash [../page-links#test](../page-links#test)
* relative hash [../page-links/#test](../page-links/#test)
* just a [#test](#test)
* root hash [/#test](/#test)

### Reference links

* [../03.assets#blah][r_relative]
* [/blog/focus-and-blur#blah][r_absolute]
* [http://www.cnn.com][r_external]

### Other link types

* [xmpp:tim@boese-ban.de](xmpp:tim@boese-ban.de)
* [tel:1-555-223-2323](tel:1-555-223-2323)
* [sms:1-555-223-2323](sms:1-555-223-2323)
* [mailto:blah@blah.com](mailto:blah@blah.com)

### Remote

* remote http: [http://www.cnn.com](http://www.cnn.com)
* remote https: [https://github.com](https://github.com)

BTW I did commit a fix to add the active language to prefix the links as I missed this when doing the multilang implementation.

Scratch that last commit, had to roll that back as it broke image links. I’ll look to find a way to add active language prefix for markdown links only.

https://github.com/getgrav/grav/commit/565152dee03b714a4b601cb6331d6926f664362e <- this one should do it.

Not sure what’s wrong with my installation. I added a directory /user/page/03.blog/2015-01-11-atom-vs-coda with a file item.md
and then this markdown link to the home page which I copied from above example:

[/03.blog/2015-01-11-atom-vs-coda/item.md](/03.blog/2015-01-11-atom-vs-coda/item.md)

but the link resolves to simply plain-text http://localhost/03.blog/2015-01-11-atom-vs-coda/item.md with a 404 of course instead of the correct http://localhost/blog/2015-01-11-atom-vs-coda

Is there a plugin of some sort which must be installed/enabled for link generation? Grav is latest 0.9.42.

Nope, shouldn’t need anything special.

Can you do me a favor, please zip up your site, drop it on dropbox (or similar) and send me a link to andy at getgrav dot org.

Then I’ll check it out on my local and see if I can spot what’s going on.