简体   繁体   中英

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.

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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM