我怎样才能让 Pelican 使用 save_as 元数据来填充规范的 og:url 头部信息?

How can I get Pelican to use the save_as meta to also populate the canonical og:url head info?

使用当前 Pelican and the pelican-bootstrap3 主题。

目前我使用save_as设置应该是当前着陆页的文章。 当我这样做时,Facebook 会抛出错误,因为规范 url 不存在。

所以如果正常的 URL 会是 https://some.site/my_page.html but the save_as yields https://some.site/index.html

我的 .rst 文件元数据

:save_as: index.html

header包含。

<head>
    <title>My Page</title>
    <!-- Using the latest rendering mode for IE -->
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">



<link rel="canonical" href="/my_page.html">

        <meta name="author" content="me" />
        <meta name="keywords" content="my_page" />
        <meta name="description" content="Stuff" />

        <meta property="og:site_name" content="Stuff" />
        <meta property="og:type" content="article"/>
        <meta property="og:title" content="my_pagee"/>
        <meta property="og:url" content="/my_page.html"/>
        <meta property="og:description" content="Stuff"/>
        <meta property="article:published_time" content="2020-03-20" />
            <meta property="article:section" content="covid-19" />
            <meta property="article:tag" content="Stuff" />
            <meta property="article:author" content="me" />



    <!-- Bootstrap -->
        <link rel="stylesheet" href="/theme/css/bootstrap.min.css" type="text/css"/>
    <link href="/theme/css/font-awesome.min.css" rel="stylesheet">

    <link href="/theme/css/pygments/native.css" rel="stylesheet">
    <link rel="stylesheet" href="/theme/css/style.css" type="text/css"/>
        <link href="/css/hpt.css" rel="stylesheet">

</head>

理想情况下,pelican 会将页面保存到 "normal" URL 和 save_as,或者将规范 URL 更改为 save_as

您必须转到具有 og:url 元的模板并设置如下 jinja2 语句:

{% if page.save_as %}
<meta property="og:url" content="/{{ page.save_as }}"/>
{% else %}
<meta property="og:url" content="/{# the previous statement of the theme #}"/>
{% endif %}