Z-Blog时间因子,提交格式规范 [复制链接]

帖子链接已复制到剪贴板
V 懋和道人 (UID: 1319) 1月前

325 0

时间因子作为百度和头条搜索的重要评估标准,决定了网页内容在搜索引擎中的表现。通过分析内容的发布时间、更新时间及用户互动时间,搜索引擎能够判断其价值与相关性。定期更新内容,保持页面的新鲜度,并积极引导用户互动,能够提升网站在搜索结果中的排名,吸引更多访客。因此,理解并善用时间因子,对于网站的优化和流量增长至关重要,是达成搜索引擎排名提升的重要途径。很明显,道士我早已经实现了这个功能,不知道大家有没有发现。

image.png

直接附上小道自己的时间因子代码

{if isset($article) && $type == 'article'}
{php}
// 初始化最新评论时间变量
$lrDate_time = ''; 

// 获取最新评论的时间
$comments = $zbp->GetCommentList('*', array(array('=', 'comm_LogID', $article->ID)), array('comm_PostTime' => 'DESC'), 1, null);
if (count($comments) > 0) {
    // 如果有评论,获取最新一条评论的时间
    $lrDate_time = date('Y-m-d\TH:i:s', $comments[0]->PostTime);
} else {
    // 如果没有评论,使用文章的发布时间作为默认值
    $lrDate_time = $article->Time('PostTime', 'Y-m-d\TH:i:s');
}

// 将标签转换为直接的JSON数组
$tags = '[' . implode(',', array_map(function($tag) {
    return '"' . $tag->Name . '"';
}, $article->Tags)) . ']';

// 将所有图片URL转换为直接的JSON数组
$images = '[' . implode(',', array_map(function($image) {
    return '"' . $image . '"';
}, $article->AllImages)) . ']';

{/php}

<script type="application/ld+json">
{
    "@context": "https://ziyuan.baidu.com/contexts/cambrian.jsonld",
    "@id": "{$article.Url}",
    "appid": "1567508867852255",
    "title": "{$article.Title}",
    "images": {$images},
    "description": "{$article.Intro}",
    "pubDate": "{$article.Time('PostTime','Y-m-d\TH:i:s')}",
    "upDate": "{$article.Time('UpdateTime','Y-m-d\TH:i:s')}",
    "lrDate": "{$lrDate_time}",
    "data": {
        "webPage": {
            "headline": "{$article.Title}",
            "tag": {$tags},
            "pcUrl": "{$article.Url}",
            "wapUrl": "{$article.Url}",
            "appUrl": "{$article.Url}",
            "mipUrl": "{$article.Url}",
            "fromSrc": "{$name}",
            "datePublished": "{$article.Time('PostTime','Y-m-d\TH:i:s')}"
        }
    }
}
</script>

<meta property="bytedance:published_time" content="{$article.Time('PostTime','Y-m-d\TH:i:s')}" />
<meta property="bytedance:updated_time" content="{$article.Time('UpdateTime','Y-m-d\TH:i:s')}" />
<meta property="bytedance:lrDate_time" content="{$lrDate_time}" />
{/if}

粘贴在Z-Blog的主题head头部模板就可以了,如果觉得有用,请尽情施舍道士,道士会很喜欢的。

米表,www.dao.js.cn/mi
已有评论 (0)
提示:您必须 登录 才能查看此内容。
创建新帖
广告推广点击空位自助购买