Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/mongodb/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Mongodb Jekyll和Strapi:液体异常:请确保Strapi服务器正确运行_Mongodb_Jekyll_Static Site_Strapi_Headless Cms - Fatal编程技术网

Mongodb Jekyll和Strapi:液体异常:请确保Strapi服务器正确运行

Mongodb Jekyll和Strapi:液体异常:请确保Strapi服务器正确运行,mongodb,jekyll,static-site,strapi,headless-cms,Mongodb,Jekyll,Static Site,Strapi,Headless Cms,我目前正努力学习本教程(),在“帖子列表”步骤之前,一切都很顺利。添加_layouts/home.html文件并重新启动jekyll服务器(bundle exec jekyll serve)后,我收到一条错误消息: 液体异常:Strapi服务器发送了一个错误,状态如下:404。请确保它正确运行。在/_layouts/home.html中 jekyll 3.8.5 |错误:Strapi服务器发送了一个错误,状态如下:404。请确保它正确运行。 问题是,strapi服务器正在运行。。。我可以访问st

我目前正努力学习本教程(),在“帖子列表”步骤之前,一切都很顺利。添加_layouts/home.html文件并重新启动jekyll服务器(bundle exec jekyll serve)后,我收到一条错误消息:

液体异常:Strapi服务器发送了一个错误,状态如下:404。请确保它正确运行。在/_layouts/home.html中 jekyll 3.8.5 |错误:Strapi服务器发送了一个错误,状态如下:404。请确保它正确运行。 问题是,strapi服务器正在运行。。。我可以访问strapi admin后端,我可以访问并查看Posts json对象

事实上,我不太确定到底发生了什么,以及如何解决这个问题。文档没有帮助,我似乎也无法在google或stack overflow中找到关于此问题的任何信息

还有谁知道这个问题吗

以下是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>

终于让它工作了。。。我最终将jekyll strapi更新为最新版本0.1.2,并将jekyll更新为3.8.5

我已经安装了gem jekyll strapi,所以为了更新它,我在终端中安装了:

gem install jekyll-strapi
这将确保您拥有最新版本的bug修复程序

接下来,您的gemfile应按如下方式配置:

gem "jekyll", "~> 3.8.5"
[...]
group :jekyll_plugins do
  gem "jekyll-feed", "~> 0.12"
  gem 'jekyll-strapi', github: 'strapi/jekyll-strapi'
end
“github:'strapi/jekyll-strapi'”参数将确保您拥有臭名昭著的bug的最新修复程序:“液体异常:无法将整数转换为字符串”

还有一件事,在blog/_config.yml中,而不是“type:post”

您需要将“post”设为复数。因此,您将以以下方式结束:

strapi:
  collections:
    posts:
      type: posts
如果不这样做,则会出现以下错误:“液体异常:Strapi服务器发送了一个错误,状态如下:404。请确保它正确运行。in/\u layouts/home.html”


我希望它能帮助其他正在努力学习本教程的人。随着gems和框架的快速移动和更新,一些在线教程变得过时,与最新版本不同步。

请发布配置文件好吗?具体来说,您已经包括了关于您的strapi端点等的信息。
strapi:
  collections:
    posts:
      type: post
strapi:
  collections:
    posts:
      type: posts