【问题标题】:Posts not rendering on home page with Jekyll使用 Jekyll 无法在主页上呈现帖子
【发布时间】:2018-05-07 17:56:44
【问题描述】:

我想帮助了解为什么我的帖子没有出现在 Jekyll 博客的主页上。它在本地和 GitHub 页面上无法正常工作。

我在_posts 文件夹中有一些测试帖子(即2017-11-22-a-post-about-my-research.markdown2014-11-28-markdown-and-html.md

这里是这些帖子的一个例子

--
layout: post
title: Feature images
feature-img: "assets/img/sample_feature_img.png"
---
This is an example of a post which includes a feature image specified in the front matter of the post. The feature image spans the full-width of the page, and is shown with the title on permalink pages.

服务器启动,但帖子不在主页上。

另一方面,我可以看到并打开 tags 页面上的帖子。

我的项目结构是

我的 gem 文件看起来像:

source "https://rubygems.org"

# Hello! This is where you manage which Jekyll version is used to run.
# When you want to use a different version, change it below, save the
# file and run `bundle install`. Run Jekyll with `bundle exec`, like so:
#
#     bundle exec jekyll serve
#
# This will help ensure the proper Jekyll version is running.
# Happy Jekylling!
gem "jekyll", "~> 3.6.2"

# This is the default theme for new Jekyll sites. You may change this to anything you like.
# gem "minima", "~> 2.0"
gem "jekyll-theme-type"

# If you want to use GitHub Pages, remove the "gem "jekyll"" above and
# uncomment the line below. To upgrade, run `bundle update github-pages`.
# gem "github-pages", group: :jekyll_plugins

# If you have any plugins, put them here!
group :jekyll_plugins do
  gem "jekyll-feed", "~> 0.6"
  gem "jekyll-paginate"
end

# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]

我的 conf.yml 是关于:

# SITE CONFIGURATION
baseurl: "/blog"
url: "localhost:4000/"

# THEME-SPECIFIC CONFIGURATION
theme_settings:
  # Meta
  title: Nielsen Rechia data scientist
  avatar: assets/img/avatar.png
  favicon: assets/favicon.ico
  gravatar: # Email MD5 hash
  description: "A website with blog posts and pages" # used by search engines

  # Header and footer text
  header_text: >
     <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>

     <p>Remove all header text in <code>_config.yml</code> to disable this feature.</p>
  header_text_feature_image:
  footer_text: >
   Powered by <a href="https://jekyllrb.com/">Jekyll</a> with <a href="https://github.com/rohanchandra/type-theme">Type Theme</a>

  # Icons
  rss: false
  email_address: # Full email address, e.g. "sam@example.com"
  behance:
  bitbucket:
  dribbble:
  facebook:
  flickr:
  gitlab:
  github: "nielsenrechia"
  google_plus:
  instagram:
  linkedin:  # Full URL
  pinterest:
  reddit:
  soundcloud:
  stack_exchange:  # Full URL
  steam:
  tumblr:
  twitter: "twitter"
  wordpress:
  youtube:

  # Scripts
  google_analytics: # Tracking ID, e.g. "UA-000000-01"
  disqus_shortname:
  katex: true # Enable if using math markup
  search: True # Enable the search feature


  # Localization strings
  str_follow_on: "Follow on"
  str_rss_follow: "Follow RSS feed"
  str_email: "Email"
  str_next_post: "Next post"
  str_previous_post: "Previous post"
  str_next_page: "Next"
  str_previous_page: "Prev"
  str_continue_reading: "Continue reading"
  str_javascript_required_disqus: "Please enable JavaScript to view comments."
  str_search_no_results: "No results found."

  # Colours, typography and padding
  # Open the "_sass > base" folder, and open "_variables.scss"
  google_fonts: "Source+Sans+Pro:400,700,700italic,400italic"

  # Post navigation
  post_navigation: True

# PAGINATION
paginate: 2
paginate_path: "/blog/page:num"

# BUILD SETTINGS
publish: True
markdown: kramdown
highlighter: rouge
sass:
  sass_dir: _sass
  style: :compressed
plugins: [jekyll-paginate]
theme: jekyll-theme-type
exclude:
  - Gemfile
  - Gemfile.lock

我认为这很简单,但我无法弄清楚问题所在。

谢谢

【问题讨论】:

    标签: ruby-on-rails jekyll blogs jekyll-paginator jekyll-theme


    【解决方案1】:

    这里的问题是你有一个index.md 一个index.html。默认情况下,index.md 被处理为 _site/index.html。因此,现在 Jekyll 很困惑,哪个index.html 需要写入_site 目录,因此任何一个都会得到偏好。

    解决方案是index.md中的任何内容添加到index.html并删除index.md

    【讨论】:

    • 完美!现在可以了!在readme 文件中写到html.md 默认为空,我必须保持这种状态,但删除它后,帖子会出现在主页上!谢谢!
    【解决方案2】:

    Github 页面不支持你选择的主题gem "jekyll-theme-type",它支持:

    • 建筑师
    • 开曼
    • 小鬼
    • 黑客
    • 闰日
    • 梅洛
    • 午夜
    • 最小值
    • 最小
    • 现代主义
    • 石板
    • 触觉
    • 时光机

    来源:https://pages.github.com/themes/

    您还应该使用github-pages gem。

    【讨论】:

    • 好的,我知道了,但是问题也在本地服务器上!
    猜你喜欢
    • 2017-02-25
    • 2020-08-27
    • 2018-09-07
    • 1970-01-01
    • 1970-01-01
    • 2022-12-13
    • 2013-07-27
    • 2022-10-15
    • 1970-01-01
    相关资源
    最近更新 更多