【问题标题】:How do I remove the .html extension from not only posts, but pages as well in Jekyll?在 Jekyll 中,如何从帖子和页面中删除 .html 扩展名?
【发布时间】:2015-01-26 00:33:55
【问题描述】:

在我的 Jekyll 配置文件中,我将永久链接设置为 permalink: /:year/:month/:day/:title/,以便从帖子中删除 HTML 扩展名,但这仅适用于降价帖子,不适用于页面。

如果我希望我的所有页面都删除 .html,例如我的 about.html 页面更改为 /about,我是否必须创建文件夹然后拥有 index.html,或者 Jekyll 有什么方法可以帮我做吗?

【问题讨论】:

    标签: jekyll


    【解决方案1】:

    _config.yml 中的此设置将起作用:

    # applies pretty for all
    permalink: pretty
    
    # overrides permalink for posts
    defaults:
      -
        scope:
          path: ""
          type: "posts"
        values:
          permalink: /:year/:month/:day/:title/
    

    请注意,页面前端的永久链接将覆盖配置中的永久链接。

    【讨论】:

      【解决方案2】:

      检查 YAML 配置文件的设置:

      #for all pages
      permalink: pretty
      
      #for posts
      defaults:
        - scope:
           path: ""
           type: "posts"
          values:
           permalink: /blog/:title
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2013-01-09
        • 2017-05-08
        • 2016-04-18
        • 2015-03-20
        • 1970-01-01
        • 1970-01-01
        • 2023-02-19
        相关资源
        最近更新 更多