I am currently developing a personal blog using Jekyll (using this blog post for an easy setup guide). I am trying to re-use an HTML file so that one url "/"
displays some text while a different url "/posts"
displays something slightly different. To do this, I am trying to set a Font Matter Default
in _config.yml
that will only apply to one of the paths, the home path "/"
.
Here's the code I'm using to set up the Font Matter Default:
# site defaults (https://jekyllrb.com/docs/configuration/)
defaults:
- scope:
path: ""
values:
display_num_posts: 5
The issue I'm facing is that path: ""
applies to all pages, so my variable display_num_posts
will be set to 5
on every page where my HTML file is used (both "/"
and "/posts"
).
My question: How can I set a path to only include the home page? With no extra "/posts"
in the url?
I've tried searching on the https://jekyllrb.com/docs/ page, but couldn't find an answer. I also tried setting path: "/"
, but that path didn't match any url at all.
Apparently this can be done by setting the path
to the base index.html
file like this:
# site defaults (https://jekyllrb.com/docs/configuration/)
defaults:
- scope:
path: "index.html"
values:
display_num_posts: 5
I found this was possible on this blog post.
Hope this helps someone as it helped me.