Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
jbake-org#294
This pull request implements Permalink/URI Generation and customization in JBake.
It is driven by a property
permalink
in jbake.properties file. Sample permalink pattern can bepermalink=/:blog:/:title
which will generate urls asblog\first-post.html
.If
permalink
is not specified then default pattern is/:filepath
.Every keyword should be separated with '/:'. It allows you to use any keywords from content header. eg.
/:slug/:tags/:title
.Few Rules:
Some keywords are reserved for specific format. Below is the list of such keywords -
/:filepath
: This keyword will result it addition of relative source file path fromcontent
folder. If you want to maintain the content folder structure in output then,permalink=/:filepath
will result in generating URI structure same as source files./:filename
: This keyword will result in addition of source file name (without extension)./:YEAR
,/:MONTH
,:DAY
: These keywords will add a related date part from content published date to url.permalink=/:blog:/:filename
will result in generation of urls like /blog/First-post.htmlUsing permalink in templates
Generated permalinks can be accessed in templates as
content.permalink
.Extension-less permalinks
If
ur.noExtension
is set totrue
then all permalinks will be extension-less. For example,permalink=/:blog:/:filename
will generate/blog/First-post/
.How to use different permalink patterns for each content type.
It is possible to use different permalink patterns based on content type. For example, post and page content type can use their own permalink patterns.
permalink
property will always be used as a default pattern for every content. To customize it based on content type, you can add another propertypermalink.{type}
and specify pattern for it.Sample configuration -
permalink=/:filepath
permalink.post=/:blog:/:filename
permalink.page=/:filename
Above configuration will result in pages with uri as filenames only, while posts will have suffix /blog/ for url. Any other content type will keep using
/:filepath
pattern.