Possible build bug on Github

Hi there,

I’m not too sure where to post this, but I ran into this problem that the site built by Jekyll on Github was different from the one built on my local computer (in the _site folder).

Here’s how the pre-built code looks like:

<a class="post_catalog_title" href="{{site.baseurl}}{{post.url}}">
    <h1 class="medium-title">{{post.title}}</h1>
    <span class="article_excerpt">{{post.excerpt | strip_html | markdownify | truncatewords: 50}}</span>
    <span class="read_more">Read More</span>
</a>

Here’s the HTML rendered by Jekyll in my _site folder:

<a class="post_catalog_title" href="/link/to/my/blog/post">
    <h1 class="large-title">My title here</h1>
    <span class="article_excerpt"><p>My contents here...</p></span>
    <span class="read_more">Read More</span>
</a>

Here’s the HTML rendered on my Github Pages site:

<a class="post_catalog_title" href="/link/to/my/blog/post">
    <h1 class="large-title">My title here</h1>
    <span class="article_excerpt"></span>
</a>
<p>
    <a class="post_catalog_title" href="/link/to/my/blog/post">
        My contents here...
        <span class="read_more">Read More</span>
    </a>
</p>

Note that the problem only happened for excerpts that have been truncated.

So what should I do?

Ensure that you’re running only supported plugins (and versions) while pushing to host on GitHub Pages

A

Thanks for pointing that out :smile:

So since the newer Jekyll version seems to have fixed this generation, I suppose I should just wait for Github Pages to update their dependency version?

You can also try a workaround by explicitly defining what you want the excerpt to look like. Put something like this inside your for loop:

{% assign post_excerpt = post.content | truncatewords: 50 %}

and output via:

<span class="article_excerpt">{{ post_excerpt | strip_html | markdownify }}</span>

1 Like

That’s a clever workaround! Thanks jreel!