Paul Verest
Paul Verest

Reputation: 63902

GitHub Jekyll cannot find posts

I have a Markdown page index2.md as follow:

---
layout: plain
title: Index2
---

test Index2


<ul class="posts">
    {% for post in site.posts %}
      <li><span>{{ post.date | date_to_string }}</span> &raquo; <a href="{{ post.url }}">{{ post.title }}</a></li>
    {% endfor %}
</ul>

However this can't show my blog posts

<body>
    <div class="wrapper">
      <header>
        <h1>Nodeclipse.github.io</h1>
        <p>Resource for Nodeclipse developers</p>


        <p class="view"><a href="https://github.com/Nodeclipse">View My GitHub Profile</a></p>

      </header>
      <section>
            <div>            
            <p>test Index2</p>

<p>  <ul class="posts"></p>

<p>  </ul></p>

            </div>
      </section>
      <footer>
        <p><small>Hosted on GitHub Pages &mdash; Theme by <a href="https://github.com/orderedlist">orderedlist</a></small></p>
      </footer>
    </div>
    <script src="javascripts/scale.fix.js"></script>

  </body>

That is blog list is empty.

Upvotes: 0

Views: 540

Answers (1)

Daniel Baird
Daniel Baird

Reputation: 2299

Markdown is interpreting your indented HTML as content, and helpfully wrapping it in a <p> tag for you.

Markdown will pass HTML through raw, which is what you want, but only if the starting and ending tags are not indented at all. So, un-indent the opening and closing <ul> and </ul> tags, and Markdown will let the entire chunk of HTML go unmolested. So it should look like this:

test Index2

<ul class="posts">
    {% for post in site.posts %}
        <li>
            <span>{{ post.date | date_to_string }}</span>
            &raquo;
            <a href="{{ post.url }}">{{ post.title }}</a>
        </li>
    {% endfor %}
</ul>

Upvotes: 2

Related Questions