![]() If either file in the mix is moved, changing the path between them, the link can be broken. With relative links, the location of the source file is every bit as important as that of the destination. This can be as simple as linking to another file in the current directory, such as an image file, or as complex as going up several directory levels and then back down to the specific folder/file you need to have displayed. Directory relativeĭirectory Relative links use destinations set relative to the current page. The slug placed in the header of item.md replaces the green slug from the defaulting folder name. This next example does a very similar thing, linking from pages/01.blue/01.sky/item.md to pages/02.green/02.tree/item.md, but when loading the item.md file, a slug has been assigned to the file of tree-is-green. The file, item.md, has no assigned slug, so Grav uses the directory name. In this example, we're moving up a directory and loading the default page located in the pages/01.blue/02.water/item.md directory from pages/01.blue/01.sky/item.md. Here are a few examples of slug-relative links. Grav ignores them when creating the slug, so your site's URL structure is cleaner. You don't have to include these numbers with slug-relative links. The blog post itself can be assigned a slug that makes more sense, such as grass or grass-is-green.ĭirectory names also have numbers assigned which helps with ordering. For example, a blog might use the standard file name item.md for each blog post. ![]() Grav's templating engine uses file names to determine which template to apply to them. This makes creating quick links easy as you don't have to remember the specific file name, but an easily remembered (and relevant) slug. It can also pull slugs assigned both in the header of the file, as well as the fallback directory name. Grav doesn't just limit your internal links to specific names within your file/directory structure. When used in the link, it indicates a move up a directory. This is placed directly after the square bracket. ![]() The parenthesis is used to surround the link itself. In HTML, this would be the content placed between and. The square bracket is used to wrap the text or alternate content that becomes linked.
0 Comments
Leave a Reply. |