xiaoheiAh/hugo-theme-pure

启动Hugo服务报错:range can't iterate over

hadyang opened this issue · 8 comments

错误信息:

ERROR 2019/12/30 12:53:52 render of "page" failed: "/Users/hadyang/Documents/hadyang.github.io/themes/pure/layouts/_default/single.html:4:12": execute of template failed: template: _default/single.html:4:6: executing "content" at <partial "article.html" .>: error calling partial: "/Users/hadyang/Documents/hadyang.github.io/themes/pure/layouts/partials/article.html:4:12": execute of template failed: template: partials/article.html:14:12: executing "partials/article.html" at <partial "post/category.html" .>: error calling partial: "/Users/hadyang/Documents/hadyang.github.io/themes/pure/layouts/partials/post/category.html:4:12": execute of template failed: template: partials/post/category.html:4:12: executing "partials/post/category.html" at <.>: range can't iterate over Java

Hugo版本:
Hugo Static Site Generator v0.62.0/extended darwin/amd64 BuildDate: unknown

配置文件:

baseURL: https://hadyang.github.io/
languageCode: zh-CN
title: HadYang
theme: pure
defaultContentLanguage: zh  # en/zh/...
footnoteReturnLinkContents: ↩
hasCJKLanguage: true
paginate: 7
enableEmoji: true
permalinks:
  posts: /:year/:month/:filename/

taxonomies:
    category : categories
    tag : tags
    series : series

outputFormats:          # use for search. recommend not to modify 
  SearchIndex:
    mediaType: "application/json"
    baseName: "searchindex"
    isPlainText: true
    notAlternative: true

outputs:
    home: ["HTML","RSS","SearchIndex"]  # recommend not to modify
# sitemap
sitemap:
  changefreq: monthly
  filename: sitemap.xml
  priority: 0.5

menu:
  main:
    - identifier: home
      name: Home
      weight: 1
      url: /
    - identifier: tags
      name: Tags
      weight: 2
      url: /tags
    - identifier: categories
      name: Categories
      weight: 3
      url: /categories
  # Sidebar only the following widgets. you can remove any you don't like it.

params:
  since: 2017
  dateFormatToUse: "2006-01-02"
  enablePostCopyright: true
  # the directory under content folder that you want to render
  mainSections: ["posts"]
  # Enable/Disable menu icons
  # Icon Reference: http://blog.cofess.com/hexo-theme-pure/iconfont/demo_fontclass.html
  enableMathJax: true #Enable mathjax support, to use mathematical notations
  highlightjs:
    langs: ["python", "javascript"] # refer to http://staticfile.org/, search highlight.js, already have highlight.min.js

  menuIcons:
    enable: true  # 是否启用导航菜单图标
    home: icon-home-fill
    archives: icon-archives-fill
    categories: icon-folder
    tags: icon-tags
    repository: icon-project
    books: icon-book-fill
    links: icon-friendship
    about: icon-cup-fill

  # profile
  profile:
    enabled: true # Whether to show profile bar
    avatar: avatar.png
    gravatar: # Gravatar email address, if you enable Gravatar, your avatar config will be overriden
    author: xiaoheiAh
    author_title: author title
    author_description: Good Good Study, Day Day Up~
    location: Shanghai, China
    follow: https://github.com/xiaoheiAh
    # Social Links
    social:
      links:
        github: https://github.com/xiaoheiAh
        # weibo: http://weibo.com/{yourid}
        # twitter: https://twitter.com/
        # facebook: /
        rss: /index.xml
      link_tooltip: false # enable the social link tooltip, options: true, false
  # Site
  site:
    logo:
      enabled: true
      width: 40
      height: 40
      url: favicon.ico
    title: Hugo # 页面title
    favicon: favicon.ico
    board: <p>enjoy~</p> # 公告牌

  # Share
  # weibo,qq,qzone,wechat,tencent,douban,diandian,facebook,twitter,google,linkedin
  share:
    enable: true # 是否启用分享
    sites: weibo,qq,wechat,facebook,twitter # PC端显示的分享图标
    mobile_sites: weibo,qq,qzone # 移动端显示的分享图标

  # Comment
  comment:
    type:  # type disqus/gitalk/valine 启用哪种评论系统
    disqus: your_disqus_name # enter disqus shortname here
    gitalk: # gitalk. https://gitalk.github.io/
      owner: #必须. GitHub repository 所有者,可以是个人或者组织。
      admin: #必须. GitHub repository 的所有者和合作者 (对这个 repository 有写权限的用户)。
      repo:  #必须. GitHub repository.
      ClientID: #必须. GitHub Application Client ID.
      ClientSecret: #必须. GitHub Application Client Secret.
    valine: # Valine. https://valine.js.org
      appid: # your leancloud application appid
      appkey: # your leancloud application appkey
      notify: # mail notifier , https://github.com/xCss/Valine/wiki
      verify: # Verification code
      placeholder: enjoy~ # comment box placeholder
      avatar: mm # gravatar style
      meta: nick,mail # custom comment header
      pageSize: 10 # pagination size
      visitor: false # Article reading statistic https://valine.js.org/visitor.html

  # Donate
  donate:
    enable: false
    # 微信打赏
    wechatpay:
      qrcode: donate/wechatpayimg.png
      title: 微信支付
    # 支付宝打赏
    alipay:
      qrcode: donate/alipayimg.png
      title: 支付宝

  # PV
  pv:
    busuanzi:
      enable: false # 不蒜子统计
    leancloud:
      enable: false # leancloud统计
      app_id: # leancloud <AppID>
      app_key: # leancloud <AppKey>

  # wordcount
  postCount:
    enable: true
    wordcount: true # 文章字数统计
    min2read: true # read time 阅读时长预计

  # config
  config:
    skin: # theme color default is white. other type [theme-black,theme-blue,theme-green,theme-purple]
    layout: main-center # main-left main-center main-right
    excerpt_link: Read More
    toc: true

  # Sidebar
  sidebar: right

  # Search
  search:
    enable: true # enable search. thanks for https://raw.githubusercontent.com/ppoffice/hexo-theme-icarus/master/source/js/insight.js

  # Sidebar only the following widgets. you can remove any you don't like it.
  widgets:
    - board
    - category
    - tag
    - recent_posts

params:
 email: shihaoyang129@gmail.com
 github: https://github.com/hadyang
 image: resources/img/IMG_3162.JPG

错误日志截全了吗?看不太出来

完整的错误日志

hugo server -t pure
Building sites … ERROR 2019/12/30 18:19:18 render of "home" failed: "/Users/hadyang/Documents/tech_blog/themes/pure/layouts/index.html:4:12": execute of template failed: template: index.html:26:12: executing "content" at <partial "post/category.html" .>: error calling partial: "/Users/hadyang/Documents/tech_blog/themes/pure/layouts/partials/post/category.html:4:12": execute of template failed: template: partials/post/category.html:4:12: executing "partials/post/category.html" at <.>: range can't iterate over Java
ERROR 2019/12/30 18:19:18 render of "page" failed: "/Users/hadyang/Documents/tech_blog/themes/pure/layouts/_default/single.html:4:12": execute of template failed: template: _default/single.html:4:6: executing "content" at <partial "article.html" .>: error calling partial: "/Users/hadyang/Documents/tech_blog/themes/pure/layouts/partials/article.html:4:12": execute of template failed: template: partials/article.html:14:12: executing "partials/article.html" at <partial "post/category.html" .>: error calling partial: "/Users/hadyang/Documents/tech_blog/themes/pure/layouts/partials/post/category.html:4:12": execute of template failed: template: partials/post/category.html:4:12: executing "partials/post/category.html" at <.>: range can't iterate over Java
ERROR 2019/12/30 18:19:18 render of "page" failed: "/Users/hadyang/Documents/tech_blog/themes/pure/layouts/_default/single.html:4:12": execute of template failed: template: _default/single.html:4:6: executing "content" at <partial "article.html" .>: error calling partial: "/Users/hadyang/Documents/tech_blog/themes/pure/layouts/partials/article.html:4:12": execute of template failed: template: partials/article.html:14:12: executing "partials/article.html" at <partial "post/category.html" .>: error calling partial: "/Users/hadyang/Documents/tech_blog/themes/pure/layouts/partials/post/category.html:4:12": execute of template failed: template: partials/post/category.html:4:12: executing "partials/post/category.html" at <.>: range can't iterate over 设计模式
ERROR 2019/12/30 18:19:18 render of "page" failed: "/Users/hadyang/Documents/tech_blog/themes/pure/layouts/_default/single.html:4:12": execute of template failed: template: _default/single.html:4:6: executing "content" at <partial "article.html" .>: error calling partial: "/Users/hadyang/Documents/tech_blog/themes/pure/layouts/partials/article.html:4:12": execute of template failed: template: partials/article.html:14:12: executing "partials/article.html" at <partial "post/category.html" .>: error calling partial: "/Users/hadyang/Documents/tech_blog/themes/pure/layouts/partials/post/category.html:4:12": execute of template failed: template: partials/post/category.html:4:12: executing "partials/post/category.html" at <.>: range can't iterate over Java
Built in 212 ms
Error: Error building site: failed to render pages: render of "home" failed: "/Users/hadyang/Documents/tech_blog/themes/pure/layouts/index.html:4:12": execute of template failed: template: index.html:26:12: executing "content" at <partial "post/category.html" .>: error calling partial: "/Users/hadyang/Documents/tech_blog/themes/pure/layouts/partials/post/category.html:4:12": execute of template failed: template: partials/post/category.html:4:12: executing "partials/post/category.html" at <.>: range can't iterate over Java

抱歉,超出认知了.建议google下.这两个tag 我这试了没有渲染问题

这是我的仓库,https://github.com/hadyang/tech_blog , 用 hugo server -t pure 你试试

front matter 解析有问题,我改改试试.

我发现你的categories写法应该是不规范的,如果是
categories : ["Java"]
或者就不会报错.

categories: 
    - Java

你可以尝试一下.你是不是从hexo直接转过来的?

我试试,是从hexo转过来的

可以了,确实是这个问题,谢谢