I am building my blog using Jekyll, and originally planned to only use Jekyll for the homepage. Because of this, I had created other non-changing html pages in their respective directories, and they work just fine. However, I've recently been thinking about making a separate page to list all posts I've made thus far, and would thus need to reference the "main" site's posts.
My project's structure looks like the following:
_includes/
footer.html
header.html
sidebar.html
_layouts/
default.html
posts.html
_posts/
...
_site/
...
about/
index.html
archive/
index.html
css/
style.css
resume/
index.html
_config.yml
index.html
I would like to list all posts I've made in the archive/index.html page. I attempted this by doing the following:
...
<h2>The Archive.</h2>
{% for post in site.posts %}
<h4><a href="{{ post.url }}">{{ post.title }}</a></h4>
<p><small>{{ post.date | date: "%B %e, %Y" }}</small></p>
{% endfor %}
...
However, that archive/index.html page only renders the above as text.
I have also tried creating an entirely new Jekyll directory structure inside the archive directory, but this doesn't seem to work either.
How can I make it so that the archive/index.html page recognizes the for loop for listing all my site's posts?
I've forked your repo and this archive/index.html
works well :
---
layout: default
---
<h2>The Archive.</h2>
{% for post in site.posts %}
<h4><a href="{{ post.url }}">{{ post.title }}</a></h4>
<p><small>{{ post.date | date: "%B %e, %Y" }}</small></p>
{% endfor %}