#<Hash:0x00007fed774d2a3>的未定义方法'gsub'(NoMethodError)

时间:2019-10-09 10:33:44

标签: jekyll netlify netlify-cms

我试图用NetlifyCMS连接Jekyll安装。我使用的自定义主题在没有CMS部分的情况下仍然可以正常运行,但是当我按照NetflifyCMS docs I进行集成时,会出现此错误。

~/.rvm/gems/ruby-2.5.1/gems/jekyll-3.4.1/lib/jekyll/collection.rb:158:in `sanitize_label': undefined method `gsub' for #<Hash:0x00007fed774d2a3

我正在Mac OSX上运行它,这是我的config.yml。相关部分是收集部分:

collections:
  - name: 'docs'
    output: true
    label: 'Docs'
    folder: '_docs/'
    create: true
    slug: '{{year}}-{{month}}-{{day}}-{{slug}}'
    editor:
      preview: false
    fields:
      - { label: 'Layout', name: 'layout', widget: 'hidden', default: 'post' }
      - { label: 'Title', name: 'title', widget: 'string' }
      - { label: 'Publish Date', name: 'date', widget: 'datetime' }
      - { label: 'Body', name: 'body', widget: 'markdown' }
  - name: 'faqs'
    output: false
    label: 'Faqs'
    folder: '_faqs/'
    create: true
    slug: '{{year}}-{{month}}-{{day}}-{{slug}}'
    editor:
      preview: false
    fields:
      - { label: 'Layout', name: 'layout', widget: 'hidden', default: 'post' }
      - { label: 'Title', name: 'title', widget: 'string' }
      - { label: 'Publish Date', name: 'date', widget: 'datetime' }
      - { label: 'Body', name: 'body', widget: 'markdown' }
  - name: 'changelogs'
    output: false
  - name: 'blog'
    output: true
    label: 'Blog'
    folder: '_posts/'
    create: true
    slug: '{{year}}-{{month}}-{{day}}-{{slug}}'
    editor:
      preview: false
    fields:
      - { label: 'Layout', name: 'layout', widget: 'hidden', default: 'post' }
      - { label: 'Title', name: 'title', widget: 'string' }
      - { label: 'Publish Date', name: 'date', widget: 'datetime' }
      - { label: 'Body', name: 'body', widget: 'markdown' }

1 个答案:

答案 0 :(得分:0)

发现了问题。 NetlifyCMS文档不清楚。这些集合应该已经放在./admin/config.yml中,而我正在将它们放入主config.yml文件中。