百度熊掌号是内容和服务提供者入驻百度生态的实名账号,致力于帮助内容和服务提供者方便、快捷、高效地连接百度用户,并充分利用搜索生态开放的优势,获得流量和沉淀用户,实现自身价值的快速增长。
粉丝关注改造
粉丝关注改造中有两个功能,一是添加熊掌号ID声明,而是添加关注功能代码。
添加熊掌号ID声明的时候,只需要在页面标签前添加代码
1
| <script src="//msite.baidu.com/sdk/c.js?appid=1593711792635024"></script>
|
在本地的路径为
1
| blog/themes/next/layout/_layout.swig
|
找到如下代码:
1 2 3 4 5 6 7 8 9 10
| <html class="{{ html_class | lower }}" lang="{{ config.language }}"> <head> {{ partial('_partials/head/head.swig', {}, {cache: theme.cache.enable}) }} {% include '_partials/head/head-unique.swig' %} <title>{% block title %}{% endblock %}</title> {% include '_third-party/analytics/index.swig' %} {% include '_scripts/noscript.swig' %} <script src="//msite.baidu.com/sdk/c.js?appid=1593711792635024"></script> </head>
|
在前加上去就可以了。
添加关注功能代码
这里为添加的是底部bar
1
| <script>cambrian.render('tail')</script>
|
在路径:
1
| <script>cambrian.render('tail')</script>
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14
| <main id="main" class="main"> <div class="main-inner"> <div class="content-wrap"> <div id="content" class="content"> {% block content %}{% endblock %} <script>cambrian.render('tail')</script> </div> {% include '_partials/comments.swig' %} </div> {% if theme.sidebar.display !== 'remove' %} {% block sidebar %}{% endblock %} {% endif %} </div> </main>
|
结构化改造
添加canonical标签
只要在
1
| /themes/next/_config.yml
|
令
添加JSON_LD数据
注意,这里站点的路径名称不能出现中文
所以我后来在写文章的时候,
1
| hexo new EN-title/Num-title
|
找到路径
1
| /themes/next/layout/_macro/post.swig
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
| <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person"> <meta itemprop="name" content="{{ theme.author }}"> <meta itemprop="description" content="{{ theme.signature }}"> <meta itemprop="image" content="{{ url_for( theme.avatar | default(theme.images + '/avatar.gif') ) }}"> </span>
<!--baidu-ldjson--> <!--问题容易出在@id上--> <!--以下是新添加的内容--> <script type="application/ld+json"> { "@context":"https://ziyuan.baidu.com/contexts/cambrian.jsonld", "@id":"{{ config.url }}{{ url_for(post.path) }}", "appid":"1593711792635024", "title":"{{ post.title }}", "images":[ "{{ config.url }}{{ url_for(post.path) }}01.jpg" ], "pubDate":"{{ moment(post.date).format('YYYY-MM-DD') }}T{{ moment(post.date).format('HH:mm:ss') }}" } </script>
|
值得注意的是,这里post为变量,变量参数的调用方法,有
1 2 3 4
| post.path post.date post.title 特别注意url_for(post.path)不能有中文
|