Clearer and more succinct explanation of slugs.

This commit is contained in:
Vas Sudanagunta 2016-02-17 00:07:17 -08:00
parent 9f8b6bb448
commit 3b301f8fcb
1 changed files with 18 additions and 16 deletions

View File

@ -8,27 +8,19 @@ Lektor's URLs in general mirror what happens on the file system as much as
possible. There are however various cases in which this behavior can be possible. There are however various cases in which this behavior can be
changed. changed.
## A URL Made of Slugs ## A URL Is Composed of Slugs
A URL in Lektor is built of slugs. What are slugs? Slugs are parts of the Each page in Lektor is associated with a string called a *slug*. The full
URL which can be customized. They are roughly speaking something like a URL of a page is its own slug concatenated with the slug of each its parents.
file name. For instance `foo-bar` can be a slug in `/foo-bar/`. The default
slug of a page is the ID of the page. So if you have a page called
`/foo/bar/contents.lr` then the default slug is `bar`. As you can see the
full URL is comprised of its own slug concatenated with all the slugs of
all parents.
Can a slug contain slashes? Yes indeed it can. A slug is free to contain The default slug is the ID of the page. So the page
any slashes if it wants and they will be handled just as you expect. So it's `content/foo/bar/contents.lr` has the default slug `bar`, its parent has the
perfectly valid for a page to have `2015/5/demo` as slug. What's not possible default slug `foo`, and its default URL would be `/foo/bar/'.
is for a page to pretend that it belongs to a different parent. The parent
paths are always added to it. So once a page has a parent page `/foo`
its URL path will always begin with the URL path of the page `foo`.
## Slug Customization ## Slug Customization
As mentioned slugs can be customized. There are three systems that control Slugs can be customized. The can even contain slashed (see below). There are
what the slug looks like: three systems that control what the slug looks like:
### Folder Name ### Folder Name
@ -55,6 +47,16 @@ of the children below it. This for instance can be used to automatically add
the date of a blog post into the slug. For more information about this the date of a blog post into the slug. For more information about this
feature see [Children & Pagination :ref](../../models/children/). feature see [Children & Pagination :ref](../../models/children/).
## Slugs Containing Slashes
Slugs can indeed contain slashes. It's perfectly valid for a page to have
`2015/5/demo` as slug, and it will still be incorporated into URLs as described
above. What's not possible is for a page to pretend that it belongs to a
different parent. The parent paths are always added to it. So once a page
has a parent page `/foo` its URL path will always begin with the URL path of
the page `foo`.
## Extensions and File Types ## Extensions and File Types
The default behavior for a page is to build into a hidden `index.html` file. The default behavior for a page is to build into a hidden `index.html` file.