方法一:

代码如下,加入全局头部模板head标签内部:

<!--QQ卡片链接-->
<meta property="og:image" <?php if($this->is('post')||$this->is('page')): ?>
content="<?php showThumbnail($this,0); ?>"<?php else: ?>
<?php if ($this->options->logoUrl){ ?>content="<?php $this->options->logoUrl();?>"<?php }else{ ?>content="<?php $this->options->siteUrl(); ?>logo.jpg"<?php };?><?php endif; ?>>
<meta property="og:title" content="<?php $this->archiveTitle(array(
'category'=>_t('%s '),
'search'=>_t('包含关键字 %s 的文章'),
'tag' =>_t('标签 %s 下的文章'),
'author'=>_t('%s 的主页')
), '', ' - '); ?><?php $this->options->title(); ?>"/>
<meta property="og:description" content="<?php $this->options->description(); ?>">  
<meta property="og:url" content="<?php $this->permalink() ?>"/>  
<meta itemprop="name" content="<?php $this->archiveTitle(array(
'category'=>_t('%s '),
'search'=>_t('包含关键字 %s 的文章'),
'tag' =>_t('标签 %s 下的文章'),
'author'=>_t('%s 的主页')
), '', ' - '); ?><?php $this->options->title(); ?>">
<meta itemprop="description" content="<?php $this->options->description(); ?>">
<meta itemprop="image" <?php if($this->is('post')||$this->is('page')): ?>
content="<?php showThumbnail($this,0); ?>"<?php else: ?>
<?php if ($this->options->logoUrl){ ?>content="<?php $this->options->logoUrl();?>"<?php }else{ ?>content="<?php $this->options->siteUrl(); ?>logo.jpg"<?php };?><?php endif; ?>>

原文链接:https://www.ruletree.club/archives/1094/

方法二:

此方法针对handsome模板。

第一步、将以下代码插入header.phphead标记内

<!-- QQ卡片链接开始 -->
<meta itemprop="name" content="标题">
<meta itemprop="image" content="图片">
<meta name="description" itemprop="description" content="描述">
<!-- QQ卡片链接结束 -->

第二步、将下面代码插入header.php中

<!-- QQ卡片链接开始 -->
<meta itemprop="name" content="<?php Content::echoTitle($this,$this->options->title,$this->_currentPage); ?>">
<?php if($this->is('index')): ?>
<meta itemprop="image" content="/logo.jpg">
<meta name="description" itemprop="description" content="<?php $this->options->description(); ?>">
<?php elseif($this->is('post')): ?>
<meta itemprop="image" content="<?php echo Content::returnHeaderImgSrc($this,'post',0,true); ?>">
<meta name="description" itemprop="description" content="<?php echo Content::excerpt(trim($this->fields->customSummary)!=''?$this->fields->customSummary:$this->excerpt,200); ?>">
<?php else: ?>
<meta itemprop="image" content="/logo.jpg">
<meta name="description" itemprop="description" content="<?php $this->options->description(); ?>">
<?php endif; ?>
<!-- QQ卡片链接结束 -->

第三步、刷新缓存

完成插入后,我们还需要验证配置是否有效并刷新QQ的缓存,这一步通常是通过访问https://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshareget_urlinfo?url=欲检测的网址来完成,例如:https://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshareget_urlinfo?url=https://www.ravo.top,如果返回的jsonp数据中包括你设置的内容,表示设置有效且缓存已经刷新完毕。视情况可能需要多次刷新。

原文链接:https://lisweb.cn/464.html

最后修改:2021 年 03 月 02 日
如果觉得我的文章对你有用,请随意赞赏鼓励!