Reputation: 11
I'm setting up a website using Jekyll and I'm struggling with the permalink structure. I have a main page for the blog section, listing all the posts, and I want the posts to have urls based on that. For example, the blog page url is
then the posts should have a url
http://example.com/blog/my_post_title/
However, when I set the posts permalink to
permalink: /blog/:title
in either the _config.yml file or in an individual post file, the main blog page stops displaying. Instead you get a page with "Index of /blog/" at the top and a WEBrick line at the bottom.
I get the same behaviour if I try setting the category of a post to blog using
category: blog
Is it possible to have the posts under main page like that or do they have to have a completely unique url?
Thanks...
Upvotes: 0
Views: 90
Reputation: 24012
To have Jekyll posts under the blog directory use the baseurl option in _config.yml:
baseurl: /blog
Base URL - Serve the website from the given base URL
Then set the permalink as "title" only:
permalink: /:title
If you put permalink: /blog/:title
in a post, it won't work, you need to specify the permalink without placeholders like /blog/this-is-my-title
.
In this case I would create a directory called blog
, and all the posts will be in blog/_posts
.
Then in _config.yml
the permalink as: permalink: /:categories/:title
. So every post in the blog
folder will have an url like: /blog/my-post-title
.
Upvotes: 0