【Hexo】maupassant 主题设置百度站点自动推送

自动推送是百度搜索资源平台为提高站点新增网页发现速度推出的工具,安装自动推送JS代码的网页,在页面被访问时,页面URL将立即被推送给百度。

进入百度搜索资源平台的 链接提交 处,将百度给出的自动推送JS代码拷贝下来:

<script>
    (function(){
        var bp = document.createElement('script');
        var curProtocol = window.location.protocol.split(':')[0];
        if (curProtocol === 'https') {
            bp.src = 'https://zz.bdstatic.com/linksubmit/push.js';
        }
        else {
            bp.src = 'http://push.zhanzhang.baidu.com/push.js';
        }
        var s = document.getElementsByTagName("script")[0];
        s.parentNode.insertBefore(bp, s);
    })();
</script>

打开主题中的 head.pug 文件,路径: yourblogdir/themes/maupassant/layout/_partial/head.pug

在该文件底部添加以上JS代码:(其中 theme.baidu_autopush是我自己设定的属性名,从 _config.yml 中引用,也可在此处直接设为true

之后打开主题配置文件,路径:yourblogdir/themes/maupassant/_config.yml,在文件任意处设置以下属性值:(注释随意加,注意左侧不能有任何空格与缩进)

baidu_autopush: true  ## Add pushing automately of baidu site.

本地使用命令hexo clean && hexo g && hexo s开启服务查看一下,就会发现页面源码中已经加上自动推送的JS代码了。

现在就靠自己手动刷刷页面让链接自动提交给百度啦,但是话说我已经通过 sitemap 让百度自动抓取了,百度接收链接还是奇慢无比,Google上早就能看到我的站点链接了 =_=!!!

发布了27 篇原创文章 · 获赞 0 · 访问量 92

猜你喜欢

转载自blog.csdn.net/charjindev/article/details/104312095