I've built a blog and would like to add specific meta data to each post in the blog.
At the start of each page I have the following code (simplified to make clear the question I'm asking).
---
layout: default
title: "Title"
date: 2018-04-19
---
Which goes off and pull in my default.html in _layout
deafault.html
<!DOCTYPE html>
<html lang="en-us">
{% include head.html %}
<body>
</body>
</html>
head.html is where I have the head portion of my website. In there, there is some general header data that I would like on every page. What I'm trying to ask is what is a good way to add page/post specific meta data to each post using Jekyll and liquid (in addition to the general meta data I have already for the overall site)? Where in the flow should I add this page/post specific metadata?
Thanks!
So did some more web searching and was able to find the following. (So all credit to this site for the following code snippets.) Which is the direct answer to my original question, but Andrei did provide a good point (see further below).
https://ehelion.com/blog/2018/02/24/adding-meta-keywords-jekyll.html
Add this to the head.html:
{% if page.keywords %}
<meta name="keywords" content="{{ page.keywords | join: ', ' | escape }}">
{% endif %}
Add this to YAML font matter:
---
layout: post
title: "Best blog post ever made"
date: 2029-01-01 16:20:00
keywords:
- some keyword
- another keyword
- get rich quick
---
Also thanks to Andrei Gheorghiu for providing that link because it explains that search engines don't really care about the keywords tag anymore. Instead the focus has shifted to meta descriptions. But the same type of code can be applied. Just swap out if page.keywords to if page.description and put a description in the YAML font matter.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With