Linking To Files And Pages

There are multiple places where you need to specify URLs to pages or paths to media files within your content. That may be a link within your markdown or a paramter for a tool or extension represented by a variable. In this regard there are some rules to be observed.


Pages

Relative URLs

Linking to pages relatively works quite self-explanatory. You can simply link from http://yoursite.com/page to http://yoursite.com/page/subpage by simply using subpage as URL. To link to any page on the same level, next to http://yoursite.com/page, use ../page2.

Absolute URLs

The root directory "/" is always the Automad base directory and not the server's root!

Absolute URLs (starting with a /) specify locations relative to Automad's base directory. It is important to understand that you don not have to prepend the base URL of your Automad installation.

For example, if you install Automad in a subdirectoy of your page like http://domain.com/automad-subdirectory, linking to / will link to http://domain.com/automad-subdirectory and not to http://domain.com. All URLs get automatically resolved to your real base URL to maintain portability.


Files

Generally, unlike linking to pages, files have a "real" path and not a virtual URL. The real path is the actual full file system path of the file like /pages/01.pagename/filename.png and NOT /url_to_page/filename.png.

Relative Paths

Whenever Automad finds a link using a relative path to a file or just a filename like image.png, that link gets resolved relative to the current page's file system path. So linking to image.png is enough, as long as a file with that name is stored in the page's location.

Absolute Paths

When linking to files in another location than the page's directory, it is recommended to use absoulte paths, starting from Automad's installation directory, for examplte /shared/logo.png.


Using Files With Tools/Extensions

All Tools and Extensions using files are designed to handle file patterns. For example, in case your template uses the gallery extension, you might have a variable to define the images to be used in the gallery. Using *.jpg will select all JPG files in the page's directory while gallery_*.png will select all PNG files starting with "gallery_". It is also possible to use more complex patterns like /pages/*/*.jpg to select all JPGs of all first level pages as an example.

Multiple Patterns

You can specify multiple patterns or files by separating them with a comma like this:

my_gallery_images: *.jpg, *.png /shared/gallery_*

The above will select all .jpg and .png files within the page's directory as well as all files within the /shared directory starting with gallery_.

See also