生成警告:index.md中请求的布局'XXX-layout'在Jekyll中不存在?

时间:2019-05-10 07:56:16

标签: php jekyll documentation gemspecs jekyll-theme

我使用自己创建的名为'north'的Jekyll创建了自己的主题。

创建主题之后,我得到了一个名为“ north-0.1.0.gem”的gem文件,一个名为“ north.gemspec”的gemspec文件。

我同时获取了这两个文件,并将其粘贴到新项目“ docs”中名为“ north”的文件夹中。

north.gemspec

frozen_string_literal: true

Gem::Specification.new do |spec|
  spec.name          = "north"
  spec.version       = "0.1.0"
  spec.authors       = ["kumar.saurabh"]
  spec.email         = ["kumar.saurabh108@abc.com"]

  spec.summary       = "test."
  spec.homepage      = "https://wkrepo.abc.com/saurabh.kumar/uvtheme/tree/2.0"
  spec.license       = "MIT"

  spec.files = `git ls-files -z`.split("\x0").select do |f|
    f.match(%r{^(_(includes|layouts|sass)/|(LICENSE|README)((\.(txt|md|markdown)|$)))}i)
  end

  spec.add_runtime_dependency "jekyll", "~> 3.8"

  spec.add_development_dependency "bundler", "~> 1.16"
  spec.add_development_dependency "rake", "~> 12.0"
end

_config.yaml

# Build settings
markdown: kramdown
theme: north
plugins:
  - jekyll-feed

index.md

---
# Feel free to add content and custom Front Matter to this file.
# To modify the layout, see https://jekyllrb.com/docs/themes/#overriding-theme-defaults

layout: page-sidebar-layout
---

宝石文件

gem "jekyll", "~> 3.8.5"

# This is the default theme for new Jekyll sites. You may change this to anything you like.
gem "north", "0.1.0", :path => "north/north-0.1.0.gem_FILES"

错误:

在终端中:

Invalid theme folder: _sass
Invalid theme folder: _includes
            Source: /home/users/kumar.saurabh/www/html/symfony_projects/UVdeskDocs/uvdocs
       Destination: /home/users/kumar.saurabh/www/html/symfony_projects/UVdeskDocs/uvdocs/_site
 Incremental build: disabled. Enable with --incremental
      Generating... 
Invalid theme folder: _layouts
Invalid theme folder: assets
       Jekyll Feed: Generating feed for posts
     Build Warning: Layout 'page-sidebar-layout' requested in _posts/2019-05-09-welcome-to-jekyll.markdown does not exist.
     Build Warning: Layout 'page-sidebar-layout' requested in 404.html does not exist.
     Build Warning: Layout 'page-sidebar-layout' requested in about.md does not exist.
     Build Warning: Layout 'page-sidebar-layout' requested in index.md does not exist.
                    done in 0.179 seconds.

我还有一个问题:

当我提取.gem文件时,我得到了'data'文件夹,其中存在_layouts,_includes和_sass文件夹,但是没有资产文件夹,尽管我在制作.gem文件时添加了'assets'文件夹。 为什么?

我遵循以下惯例: https://www.chrisanthropic.com/blog/2016/creating-gem-based-themes-for-jekyll/

1 个答案:

答案 0 :(得分:1)

首先,您已经将自己与jekyll theme-gem的技术知识和使用本地版本混淆了。

  1. 如果您不打算与Jekyll社区的其他成员共享主题,则无需创建主题宝石。
  2. 在Gemfile中使用path:属性时,无需生成xyz.gem存档。一个有效的xyz.gemspec文件就足够了。

因此理想情况下,您的目录结构应该简单地是:

north/
  north.gemspec
  _layouts/
    layoutA.html
    layoutB.html
  _includes/
    lorem.html
    ipsum.html
  _sass/
    foo.scss
    bar.scss
  assets/
    styles.scss
docs/
  Gemfile
  index.md

然后在您的Gemfile中引用主题宝石:

gem 'north', path: '../north'

  

尽管我在制作.gem文件时添加了“ assets”文件夹。

该错误在您的gemspec中:

f.match(%r{^(_(includes|layouts|sass)/|(LICENSE|README)((\.(txt|md|markdown)|$)))}i)

在上面的正则表达式中没有提到assets

您可能希望参考诸如minima之类的现有主题的存储库,以获取正确的指导。