【问题标题】:Replace page meta description in Wintersmith替换 Wintersmith 中的页面元描述
【发布时间】:2022-01-22 01:19:44
【问题描述】:

我在 Wintersmith layout.pug 中有以下行:

...  
head
  meta(name='description' content=locals.description)
...

我知道我可以在article.pug 模板中添加到 head 块中,如下所示:

...
block append head
  meta(name='author' content=#{page.meta.author})
...

但现在我有两次 description 元标题:

<meta name="description" content="The thing from config.json.">
<meta name="description" content="The thing from the individual article.">

有没有办法替换 Wintersmith 中哈巴狗模板中的标签?我想避免实际上必须在每个模板中手动添加元标记。

【问题讨论】:

    标签: pug wintersmith


    【解决方案1】:

    事实证明,您可以替换模板中的块。你只需要给它们命名。

    所以,我的layout.pug 将如下所示:

    ...
    头 块元数据 元(名称='描述'内容=locals.description) ...

    在我的article.pug 模板中,我可以替换该块:

    // top-level
    block metadesc
      (meta name='description' content=article.title)
    

    我是在回答问题而不是删除,因为我知道明年我会忘记这个问题:)

    【讨论】:

      猜你喜欢
      • 2015-08-11
      • 1970-01-01
      • 2021-10-31
      • 2011-11-06
      • 2012-05-16
      • 1970-01-01
      • 1970-01-01
      • 2011-03-20
      • 1970-01-01
      相关资源
      最近更新 更多