I'm using Jekyll to build a static site for my blog site. Jekyll uses the liquid template engine.
To reference posts (blog posts) in the _posts directory, the code in the index.html is something like this
<ul class="posts">
{% for post in site.posts %}
<!-- do stuff here -->
<div class="container">
<h4 class="card-title"><b>{{ post.title }}</b></h4>
<p class="card-author">{{ post.author }}</p>
</div>
{% endif %}
</ul>
Sample markdown file (.md) in _posts:
---
layout: default
title: "Another Blog Post!"
date: 2021-08-09 00:00:00
cover_image: "https://raw.githubusercontent.com/sharmaabhishekk/sharmaabhishekk.github.io/master/images/cover.png"
categories: main
tag: "advanced"
author: "Abhishek Sharma"
---
Hi this is a blog post!
Jekyll offers powerful support for code snippets:
{% highlight ruby %}
def print_hi(name)
puts "Hi, #{name}"
end
print_hi('Tom')
#=> prints 'Hi, Tom' to STDOUT.
{% endhighlight %}
For each of the markdown files in my _posts directory, it iterates over it and displays it appropriately. More importantly, I can use the post.<attribute> way to refer to variables I set (post.title, post.author) in the markdown file.
However, I'd like to write my posts in HTML and not markdown. I want to know how can I still
- how to iterate over the
.htmlfiles in my_postsdirectory? - how to define these values in my html file?
- how can the template engine parse through and read those variables?
For 2.), I settled on a way to use meta tags to write those values. I'm not sure if that's best practice but this is what I'm doing.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Site Title</title>
<meta name="author" content="Abhishek Sharma">
<meta name="title" content="Blog Post 1">
<meta name="date" content="10-08-2021">
</head>
But then I'm unsure how to reference these meta tag name and content pairs in my index.html liquid template.
I'd appreciate any help with this. Thank you!