Pretty URLS
Pretty URLS
Often called "pretty URLs", Tapestry will by default compile your project in a way that removes the need for the
.html file extension. For example source/about.phtml will be compiled to
build_local/about/index.html, which will be accessible from http://www.example.com/about
due to the way that web servers handle default pages.
This functionality may be disabled site wide via the pretty permalink
configuration property within your config.php or config.yaml file.
Or alternatively it may be disabled on a per file basis via setting pretty_permalink to false within the
file Frontmatter, e.g:
---
pretty_permalink: false
---
Defining custom permalinks
You can define custom permalinks on a per file basis, this is useful for when you want the file to be output to a
particular location or with a certain file extension. For example you may have the source file source/atom.phtml
which you want to output to build_local/atom.xml. This would be achieved by setting the following
Frontmatter.
---
permalink: atom.xml
---
Custom permalink template variables
The following table lists the template variables that are available for your custom permalink property.
| Variable | Description |
|---|---|
{ext} |
The current file extension. |
{filename} |
The current file filename. |
{path} |
The current files relative path, e.g. /source/folder/file.md -> folder |
{year} |
The year that the file was modified, or if it has a date set via filename or frontmatter method the year that is set. |
{month} |
The month that the file was modified, or if it has a date set via filename or frontmatter method the month that is set. |
{day} |
The day that the file was modified, or if it has a date set via filename or frontmatter method the day that is set. |
{page} |
This is a special tag that is relevant only to paginated pages, it will return the current page number. |
{category} |
This tag will consolidate all the categories that belong to the page into one string split by /. For example a file with three categories may have the result of this tag equal category1/category2/category3. This tag is special in that is has an optional limit argument: {category,1}, in the case where you pass this tag a limit it will only include categories up to that limit. |
{slug} |
The current file slug, generated from its title if one is set in the frontmatter or otherwise the filename. |