Jinja if statement not working when deploying with Netlify [FIXED]

I’m building a website with pelican, where I want my index.html to display articles in different sections sorted by categories.
So for example, I have:

<div class="home-blog-list" >
  {% for article in articles if article.category == 'news' %}
    <a href="{{ SITEURL }}/{{ article.url }}">{{ article.title }}</a>, {{ article.locale_date }}</p>
  {% endfor %}
  <a href="{{ SITEURL }}/category/news.html" class="section-link">More from the blog</a>

The html output that I’m previewing locally has articles filtered by the ‘News’ category as intended, but when I’m deploying the website with Netlify (using the pelican content -s publishconf.py build command), the list appears empty. Everything else is working fine (css, js etc load correctly), and if I remove the if statement, just keeping for article in articles, the build returns the correct list of all articles.

Any idea what is going wrong here? Why is that specific Jinja statement working when I generate my output locally but not anymore when its through Netlify?

In case someone with the same issue find this topic: this can be fixed by making Netlify use python3 instead of the default 2.7


Thank you for sharing your solution!

1 Like