【问题标题】:How to keep pages with .html suffix in eleventy (static site gen) output?如何在 110(静态站点生成)输出中保留带有 .html 后缀的页面?
【发布时间】:2020-05-23 22:25:31
【问题描述】:

我有一个现有的老式纯 html 静态网站,我想用 SSG 进行改造,我选择了 110。

网站结构如下:

+ index.html
+ somepage.html
+ otherpage.html

https://www.11ty.dev/docs/permalinks/#cool-uris-dont-change 所述,十一将创建:

+ index.html
+ somepage/index.html
+ otherpage/index.html

我不想更改我已经拥有的(不)酷的 URI :-)

我知道我可以在服务器上添加 .htaccess 重写来重写 URL。

但是是否可以配置 110 使其保持旧站点的确切结构?我想是的,但在文档中没有找到。

【问题讨论】:

    标签: static-site eleventy


    【解决方案1】:

    pdehaan 已在https://github.com/11ty/eleventy/issues/913 上回答了此问题,并提供了指向https://github.com/pdehaan/11ty-dynamic-permalink-test/ 的链接

    .eleventy.js

    module.exports = (eleventyConfig) => {
      return {
        dir: {
          input: "src",
          output: "www"
        }
      };
    };
    

    src/pages/pages.11tydata.json

    {
      "permalink": "{{ page.fileSlug }}.html"
    }
    

    这是源码目录结构

    src/
    └── pages/
        ├── index.html
        ├── otherpage.html
        ├── pages.11tydata.json
        └── somepage.html
    

    【讨论】:

      猜你喜欢
      • 2022-08-15
      • 1970-01-01
      • 2021-02-22
      • 1970-01-01
      • 1970-01-01
      • 2016-06-02
      • 1970-01-01
      • 2012-07-08
      • 1970-01-01
      相关资源
      最近更新 更多