主题配置文件

在主题配置文件_config.butterfly.yml中加入以下代码:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
# Analysis
# --------------------------------------
# Baidu Analytics
# https://tongji.baidu.com/web/welcome/login
baidu_analytics:

# Google Analytics
# https://analytics.google.com/analytics/web/
google_analytics:

+# 51la Analytics
+# https://www.51.la/
+la51_analytics:
+la51_perf:

analytics.pug

[you_blog]\themes\butterfly\layout\includes\head\analytics.pug中添加以下代码:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
if theme.google_analytics
script(async src=`https://www.googletagmanager.com/gtag/js?id=${theme.google_analytics}`)
script.
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', '!{theme.google_analytics}');

+if theme.la51_analytics
+ script#LA_COLLECT(charset='UTF-8', src='//sdk.51.la/js-sdk-pro.min.js')
+ script LA.init({id: "!{theme.la51_analytics}",ck: "!{theme.la51_analytics}",autoTrack:true})
+if theme.la51_perf
+ script(src='https://sdk.51.la/perf/js-sdk-perf.min.js', crossorigin='anonymous')
+ script new LingQue.Monitor().init({id:"!{theme.la51_perf}",sendSuspicious:true,sendSpaPv:true});

preconnect.pug

[you_blog]\Hexo_butterfly\themes\butterfly\layout\includes\head\preconnect.pug中添加以下代码:

1
2
3
4
5
if theme.baidu_analytics
link(rel="preconnect" href="//hm.baidu.com")

+if theme.la51_analytics
+ link(rel="preconnect" href="//sdk.51.la")
13-404页面展示最近文章 11.4-直达底部