Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JBake Permalinks #3

Merged
merged 3 commits into from
Jun 28, 2016
Merged

JBake Permalinks #3

merged 3 commits into from
Jun 28, 2016

Conversation

manikmagar
Copy link
Owner

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 be permalink=/:blog:/:title which will generate urls as blog\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 -

  1. /:filepath: This keyword will result it addition of relative source file path from content 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.
  2. /:filename: This keyword will result in addition of source file name (without extension).
  3. /:YEAR, /:MONTH, :DAY: These keywords will add a related date part from content published date to url.
  4. Adding Static words - Static words can be added in url by using ':' as suffix in permalink. For example, permalink=/:blog:/:filename will result in generation of urls like /blog/First-post.html

Using permalink in templates

Generated permalinks can be accessed in templates as content.permalink.

Extension-less permalinks

If ur.noExtension is set to true 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 property permalink.{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.

@manikmagar manikmagar merged commit cee25ca into mm-jbake Jun 28, 2016
pull bot pushed a commit that referenced this pull request Jan 3, 2022
This change allows to override JBake properties or define custom
properties which can be used in the templates, e.g.:
<plugin>
    <groupId>br.com.ingenieux</groupId>
    <artifactId>jbake-maven-plugin</artifactId>
    <executions>
        ...
    </executions>
    <configuration>
        <properties>
            <!-- override jbake property -->
            <render.feed>true</render.feed>
            <!-- define custom property -->
            <foo>bar</foo>
        </properties>
    </configuration>
</plugin>

To make this possible an update to JBake 2.4.0 was necessary.

This fixes #3 and resolves #11.
pull bot pushed a commit that referenced this pull request Jan 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant