ducktyped ducktyped - 1 year ago 60
Ruby Question

JekyllRB: how to create an online book (force permalink to be like chapter/1)

Jekyll by default uses specified variables to generate permalink. But in my case I need permalink to use page specific variable like

to generate url something like
instead of using date and other stuff

Answer Source

You can't use any front matter variable to create your permalinks, only the Jekyll defined keys for the type of page.

To get the URLs you're after, you could use collections, as Wickramaranga said. In your _config.yml, you define your chapters collection:

    output: true
    permalink: /chapters/:title/

Then create your chapters, e.g. /_chapters/, /_chapters/

That'd create http://localhost:4000/chapters/1/ and http://localhost:4000/chapters/2/