Creating a Jekyll blog, but not at the root of the site.
22 Aug 2020So part of getting this ‘Today I learned’ part of site going was getting a blog-style page generating, but not at the root page of the site. I had disabled it for this particular template. It took me a while to get this working, so for the sake of documentation, this is what worked:
I wanted the blog posts to be at /til/
. Then, /til/
will need to contain index.html
and a folder of _posts
.
Each post’s title has the format YYYY-MM-DD-title-word-another-title-word.md
.
The best source of documentation was this Jekyll site. I made the mistake of going to Stack Overflow.
_config.yml .
You need to indicate where the pages are to paginate. Do this in _config.yml
:
paginate: 2
paginate_path: "/til/page:num/"
There are variations on the display of the page number, but this will give you /til/page2/
, etc. I chose only 2 posts per page so I could test pagination when I only had a few posts.
index.html .
I have not yet figured out how to quote code in Markdown, when that code is html, without that code being interpreted. So here’s the file, you’ll need to rename to index.html
and delete the first line (otherwise, some other html will be added to it ….). The Jekyll page has another version which also works, but it takes up a lot of space.
The Jekyll page says not to include a permalink, and absolutely, yes, do not do that. It doesn’t work.
Troubleshooting.
When the pagination is not working, I finally figured out that sometimes deleting the whole _site
folder was needed. If in doubt, quit Jekyll, delete, try again. At some point, I was trying some other things and got the folder structure screwed up.
Also, pay attention to all of the backslashes.
For another day.
Getting excerpts to work.