I am currently trying to follow this tutorial (https://blog.strapi.io/building-a-static-website-using-jekyll-and-strapi/) and everything was working fine until the "Posts List" step. Once I added the _layouts/home.html file and restarted the jekyll server (bundle exec jekyll serve), I ended up with an error message:
Liquid Exception: The Strapi server sent a error with the following status: 404. Please make sure it is correctly running. in /_layouts/home.html jekyll 3.8.5 | Error: The Strapi server sent a error with the following status: 404. Please make sure it is correctly running.
Thing is, the strapi server IS RUNNING... I have access to the the strapi admin backend and I can access and view the Posts json object by visiting: http://localhost:1337/posts.
I'm not actually too sure what is going on and how I can fix this. Documentation doesn't help nor can I seem to find anything on this issue in google or stack overflow.
Anyone else got this issue?
Here is the content of home.html:
---
layout: default
---
<div class="home">
<h1 class="page-heading">Posts</h1>
{%- if strapi.collections.posts.size > 0 -%}
<ul class="post-list">
{%- for post in strapi.collections.posts -%}
<li>
<span class="post-meta">{{ post.createdAt | date_to_string }} by {{ post.author.username }}</span>
<h3>
<a class="post-link" href="{{ post.url | relative_url }}">
{{ post.title }}
</a>
</h3>
<!-- Display an excerpt of the article -->
<p>{{ post.content | markdownify | strip_html | truncatewords: 10 }}</p>
</li>
{%- endfor -%}
</ul>
{%- endif -%}
</div>
EDIT: added Endpoint Config
strapi:
# Your API endpoint (optional, default to http://localhost:1337)
endpoint: http://localhost:1337
# Collections, key is used to access in the strapi.collections
# template variable
collections:
# Example for a "posts" collection
posts:
# Collection name (optional). Used to construct the url requested. Example: type `foo` would generate the following url `http://localhost:1337/foo`.
type: post
# Permalink used to generate the output files (eg. /posts/:id).
permalink: /posts/:slug/
Finally got it working... I ended up updating jekyll-strapi to lastest version 0.1.2, and jekyll to version 3.8.5.
I already had the gem jekyll-strapi installed, so to update it, I did in a Terminal:
gem install jekyll-strapi
This ensure that you have the newest latest version with bug fixes.
Next, your gemfile should be configured like this:
gem "jekyll", "~> 3.8.5"
[...]
group :jekyll_plugins do
gem "jekyll-feed", "~> 0.12"
gem 'jekyll-strapi', github: 'strapi/jekyll-strapi'
end
The "github: 'strapi/jekyll-strapi'" parameter will make sure you have the latest fix for the infamous bug: "Liquid Exception: Can't convert Integer into String"
One more thing, in blog/_config.yml, instead of "type: post"
strapi:
collections:
posts:
type: post
YOU NEED TO make 'post' plural. So, you will end up with:
strapi:
collections:
posts:
type: posts
If you don't you will end up with this error: "Liquid Exception: The Strapi server sent a error with the following status: 404. Please make sure it is correctly running. in /_layouts/home.html"
I hope it helps someone else struggling with this tutorial. With gems and frameworks moving and updating fast, some online tutorial become dated and out of synch with the latest builds.