【问题标题】:Jekyll internal server error only inside blog posts (ubuntu)Jekyll 内部服务器错误仅在博客文章中(ubuntu)
【发布时间】:2016-07-22 14:08:42
【问题描述】:

当我告诉 Jekyll 为我的网站提供服务时,一切都很好,从索引到其他页面。但是,当我点击查看博客文章(任何文章)时,我开始看到这条消息:

内部服务器错误
不兼容的字符编码:UTF-8 和 ASCII-8BIT
WEBrick/1.3.1 (Ruby/2.1.5/2014-11-13) 在 127.0.0.1:4000

我在 Ubuntu 15.10 上运行 Jekyll,我正在尝试更新这个网站:http://nvinhadeluz.com

编辑---

这是我的 _config.yml:

# Welcome to Jekyll!
#
# This config file is meant for settings that affect your whole blog, values
# which you are expected to set up once and rarely need to edit after that.
# For technical reasons, this file is *NOT* reloaded automatically when you use
# 'jekyll serve'. If you change this file, please restart the server process.

# Site settings
title: Núcleo de Promoção Humana Vinha de Luz
email: contato@nvinhadeluz.com
description: > # this means to ignore newlines until "baseurl:"
O Núcleo de Promoção Humana Vinha de Luz é uma entidade filantrópica que busca proporcionar o desenvolvimento humano e social na região em que atua. Guiados pelos princípios do Cristo à luz da Doutrina Espírita, desenvolvemos uma série de atividades religiosas e educacionais. Navegue pelo site e conheça um pouco mais do nosso trabalho!
baseurl: "" # the subpath of your site, e.g. /blog
url: "http://nvinhadeluz.com" # the base hostname & protocol for your site
paginate: 3
paginate_path: "/blog/page:num/"

#Redes sociais
twitter_username:     Vinhadeluz1
facebook_username:    nucleovinhadeluz
instagram_username:   vinhadeluz
googleplus_username:  +Nvinhadeluzbh
youtube_username:     nucleovinhadeluz

# Build settings
markdown: kramdown
gems: [jekyll-paginate]
exclude: ["Gemfile", "Gemfile.lock"]
encoding: UTF-8

# Default settings
defaults:
  -
   values:
     comments: true

【问题讨论】:

  • 很抱歉,我的网站不在公共存储库中,因为它没有部署在 Github 页面上。

标签: ubuntu jekyll


【解决方案1】:

我的代码示例:

帖子示例:

--- 布局:帖子 标题:“Copasa visita Centro Pedagógico Vinha de Luz!” 日期:2015-11-12 17:40:27 -0200 分类: 新闻 作者:胡里奥 图片:copasa-visita.jpg --- Hoje o Vinha de Luz recebeu uma visita da Copasa (Companhia de Sanemanto de Minas Gerais) para uma aula sobre o uso consciente da água, e adivinhem so? Nossas crianças sabem tudo sobre o bom uso dos nossos recursos naturais!德拉姆嗯秀! Confira as fotos na galeria abaixo, e logo mais há um vídeo das crianças cantando junto com os instrutores!

帖子布局:

---
layout: default
---

{% assign author = site.data.authors[page.author] %}

<div class="wrapper" style="max-width:700px;">

<article class="post" itemscope itemtype="http://schema.org/BlogPosting">

  <header class="post-header">
    <h3 class="post-title" itemprop="name headline" style="font-           weight:bold;">{{ page.title }}</h3>
    <p class="post-meta"><time datetime="{{ page.date | date_to_xmlschema }}" itemprop="datePublished">{{ page.date | date: "%b %-d, %Y" }}</time>{% if page.author %} • <span itemprop="author" itemscope itemtype="http://schema.org/Person"><span itemprop="name">{{ author.name }}</span></span>{% endif %}
    {% include commentcount.html %}<!--Contador de comentários-->
    <span><a href="{{ page.url }}#disqus_thread"></a></span></p><!--Contador de Comentários-->
    <!-- Go to www.addthis.com/dashboard to customize your tools -->
    <div class="addthis_sharing_toolbox"></div>
  </header>


  <img src="{{ site.baseurl }}/imagens/{{ page.image }}" style="margin-bottom:50px;">



  <div class="post-content" itemprop="articleBody">
    {{ content }}


  <div style="margin-top:50px;">{% include author-box.html %}</div>
  </div>

</article>

<div style="padding-bottom:50px;">{% include disqus.html disqus_identifier=page.disqus_identifier %}</div>

</div>

我没有更改 Jekyll 的核心中的任何内容,并且该错误从无到有。抱歉,如果代码有点乱,我还在学习如何在这里做事。

【讨论】:

  • 抱歉,我不明白,您是否已设法让您的网站启动并运行?你还需要帮助吗? :)
  • 是的,我的网站已经在网络和内部服务器上启动并运行。但是,在内部服务器上,当我点击一些帖子(任何人)时,我得到了我试图描述的错误。
  • 嗯,我明白了!我很确定我以前在我的电脑上也看到过这个错误,也许我可以帮助你。你使用哪个命令来服务 Jekyll?
  • 我运行“sudo jekyll serve”。
  • 好的,今天晚些时候我会为你发布答案,我现在不在我的电脑旁。我一回到家,就会在这里尽力帮助你。 :)
【解决方案2】:

我认为该问题一定与 Jekyll 依赖项之一有关,因此您需要一个依赖项管理器,例如 Bundler

  1. 安装捆绑器

    gem install bundler 
    

    sudo gem install bundler
    
  2. 添加一个 Gemfile。导航到您的项目文件夹 cd path/to/folder 并运行:

    bundle init
    

    这将为您创建一个 Gemfile,如下所示:

    # A sample Gemfile
    source "https://rubygems.org"
    
    # gem "rails"
    
  3. 在您的代码编辑器中编辑您的Gemfile

    如果您的网站由 GitHub 托管,请将其添加到您的 Gemfile:

    source "https://rubygems.org" # or replace https for http if don't have OpenSSL installed locally
    
    gem 'github-pages'
    gem 'jekyll-paginate'
    # any other gem you use in your project
    

    如果您不在 GitHub 上托管您的网站:

    source "https://rubygems.org"
    
    gem 'jekyll', '3.1.2' # or any other Jekyll version
    gem 'jekyll-paginate'
    # any other gem you use in your project
    
  4. 运行bundle install:这将处理您需要的所有gems,并将Gemfile.lock 添加到您的项目文件夹中。

  5. 在您的 _config.yml 上,从构建中排除 GemfileGemfile.lock

    exclude: ["Gemfile", "Gemfile.lock"]
    
  6. 使用 Bundler 服务 Jekyll:

    bundle exec jekyll serve
    

    您可以在该命令中添加您想要的所有标志,例如:

    bundle exec jekyll serve --watch -baseurl ""
    

完成!

还有一件事:葡萄牙语有很多禁止字符,所以,每次你在 Yaml 前面使用 áâã 之类的东西时,请确保在 "" 之间使用:

categories: "Notícias"
author: "Júlio"

就是这样!我想你应该没事。

如果这有帮助,请告诉我,是吗? :)

【讨论】:

  • 坏消息:/不幸的是它没有工作。我一步一步地按照你的指示做,一切都很顺利。通过命令bundle exec jekyll serve 为 Jekyll 提供服务,但在单击某些帖子时仍然出现相同的错误。另外,我注意到葡萄牙语特殊字符在前面添加了一些" ",但效果不佳。
  • 嗯......你很难过。我忘了说,你在命令前加了sudo吗?我相信你会在 Linux 上需要它。好的,让我们转到第二个选项。该错误似乎与 AscII 有关。将encoding: UTF-8 添加到您的_config.yml,看看会发生什么。请编辑您的问题并在此处添加_config.yml 内容,将更容易看到您的配置。另外,您可以尝试将gem 'jekyll', '2.4.0' 添加到您的Gemfile
  • 如果有任何帮助,请尝试在这里提问:talk.jekyllrb.com 您可以直接与 Jekyll 核心开发人员交谈。
  • Virtua,我开始担心了。这些都没有修复错误!按照所有步骤操作,没有错误,但仍然无法在 Jekyll 服务器中预览博客文章。按照要求,我用配置文件编辑了我的问题。另外,我将尝试学习如何将我的网站放在 Github 上,以便你们可以看到它并尝试提供帮助。无论如何,非常感谢你已经给我的帮助。
  • 我想我找到了问题所在。我在虚拟机中安装了全新的 Jekyll,一切正常。看起来我有一个破损的包裹或其他东西。 Jekyll 再次完美运行。再次感谢您的帮助。
猜你喜欢
  • 2010-10-04
  • 1970-01-01
  • 2022-12-25
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-12-01
  • 2016-08-29
  • 1970-01-01
相关资源
最近更新 更多