hexo之jacman主题修改记录

config.yml修改

  • menu增加Resources: /userful-resources
  • widgets更改为[category, tag, links]
  • 增加sitemap
    1
    2
    sitemap:
    path: sitemap.xml
  • 更改主题颜色theme: ‘#3d85c6’
  • 主页不展开expand: false
  • 关闭文章边栏close_aside: true
  • creative_commons: by-nc-sa
  • 更改作者信息
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    author:
    intro_line1: "Hello" ## your introduction on the bottom of the page
    intro_line2: "This is my blog!" ## the 2nd line
    weibo: 5748426185 ## e.g. 5748426185 or 2176287895 for http://weibo.com/2176287895
    weibo_verifier: cd4768ca ## e.g. cd4768ca Your weibo-show widget verifier ,if you use weibo-show it is needed.
    tsina: mchsinx ## e.g. 2176287895 Your weibo ID,It will be used in share button.
    douban: ## e.g. wuchong1014 or your id for https://www.douban.com/people/wuchong1014
    zhihu: ## e.g. jark for http://www.zhihu.com/people/jark
    email: ## e.g. imjark@gmail.com
    twitter: mchsinx ## e.g. jarkwu for https://twitter.com/jarkwu
    github: mchsinx ## e.g. wuchong for https://github.com/wuchong
    facebook: ## e.g. imjark for https://facebook.com/imjark
    linkedin: ## e.g. wuchong1014 for https://www.linkedin.com/in/wuchong1014
    google_plus: ## e.g. "111190881341800841449" for https://plus.google.com/u/0/111190881341800841449, the "" is needed!
    stackoverflow: ## e.g. 3222790 for http://stackoverflow.com/users/3222790/jark
    ## if you set them, the corresponding share button will show on the footer
  • 更改友情链接
    1
    2
    links:
    Mchsinx: http://www.mchsinx.com, 导航网站
  • 更改统计代码
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    #### Analytics
    google_analytics:
    enable: true
    id: UA-64362927-1 ## e.g. UA-46321946-2 your google analytics ID.
    ## You MUST upgrade to Universal Analytics first!
    ## https://developers.google.com/analytics/devguides/collection/upgrade/?hl=zh_CN
    statcounter: # 需自行在analytics.ejs中配置参数
    enable: true
    baidu_tongji:
    enable: true
    sitecode: 3d6283374c5e33764e4cf6c0b398f634 ## e.g. e6d1f421bbc9962127a50488f9ed37d1 your baidu tongji site code
    cnzz_tongji:
    enable: true
    siteid: 1255560261 ## e.g. 1253575964 your cnzz tongji site id
    servername: s95
    ibruce_tongji: # 不蒜子计数
    enable: true
  • 增加swift_search搜索
  • 增加百度推送

增加swiftype_search搜索和百度推送

  • 在\layout_partial\after_footer.ejs中添加代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<!-- swiftype search Begin(1/2)-->
<% if(theme.swift_search.enable){ %>
<script type="text/javascript">
(function(w,d,t,u,n,s,e){w['SwiftypeObject']=n;w[n]=w[n]||function(){
(w[n].q=w[n].q||[]).push(arguments);};s=d.createElement(t);
e=d.getElementsByTagName(t)[0];s.async=1;s.src=u;e.parentNode.insertBefore(s,e);
})(window,document,'script','//s.swiftypecdn.com/install/v2/st.js','_st');

_st('install','B93BSEbFZoHzYDdVqWxH','2.0.0');
</script>
<% } %>
<!-- swiftype search End(1/2)-->

<% if(theme.baidu_push.enable){ %>
<script>
(function(){
var bp = document.createElement('script');
bp.src = '//push.zhanzhang.baidu.com/push.js';
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(bp, s);
})();
</script>
<% } %>

需要在主题配置文件中添加开关

1
2
3
4
swift_seach:
enable: true
baidu_push:
enable: true
  • 在\layout_partial\header.ejs中增加代码,插入在<% } else if(theme.baidu_search.enable){ %>之前
1
2
3
4
5
6
7
<!-- swiftype search Begin(2/2)-->
<% }else if(theme.swift_search.enable){ %>
<form class="search" accept-charset="utf-8">
<label>Search</label>
<input type="text" class="st-default-search-input" maxlength="20" placeholder="<%= __('search') %>">
</form>
<!-- swiftype search End(2/2)-->

修改百度统计和CNZZ统计,增加statcounter

  • 在\layout_partial\analytics.ejs中修改代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<% if (theme.google_analytics.enable){ %>
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');

ga('create', '<%= theme.google_analytics.id %>', 'auto');
ga('send', 'pageview');
</script>
<% } %>

<% if (theme.baidu_tongji.enable){ %>
<div style="display:none">
<script>
var _hmt = _hmt || [];
(function() {
var hm = document.createElement("script");
hm.src = "//hm.baidu.com/hm.js?<%= theme.baidu_tongji.sitecode %>";
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(hm, s);
})();
</script>
</div>
<% } %>

<% if (theme.statcounter.enable){ %>
<!-- Start of StatCounter Code for Default Guide -->
<script type="text/javascript">
var sc_project=10517493;
var sc_invisible=1;
var sc_security="a3203727";
var scJsHost = (("https:" == document.location.protocol) ?
"https://secure." : "http://www.");
document.write("<sc"+"ript type='text/javascript' src='" +
scJsHost+
"statcounter.com/counter/counter.js'></"+"script>");
</script>
<noscript><div class="statcounter"><a title="shopify visitor
statistics" href="http://statcounter.com/shopify/"
target="_blank"><img class="statcounter"
src="http://c.statcounter.com/10517493/0/a3203727/1/"
alt="shopify visitor statistics"></a></div></noscript>
<!-- End of StatCounter Code for Default Guide -->
<% } %>

<% if (theme.cnzz_tongji.enable){ %>
<div style="display:none">
<script type="text/javascript">var cnzz_protocol = (("https:" == document.location.protocol) ? " https://" : " http://");document.write(unescape("%3Cspan id='cnzz_stat_icon_<%= theme.cnzz_tongji.siteid %>'%3E%3C/span%3E%3Cscript src='" + cnzz_protocol + "<%= theme.cnzz_tongji.servername %>.cnzz.com/stat.php%3Fid%3D<%= theme.cnzz_tongji.siteid %>' type='text/javascript'%3E%3C/script%3E"));</script>
</div>
<% } %>

增加不蒜子统计

在\layout_partial\footer.ejs中修改代码,在最后一个</p>之前增加代码

1
2
3
4
5
6
7
<!-- 不蒜子统计 -->
<% if (theme.ibruce_tongji.enable){ %>
<script async src="https://dn-lbstatics.qbox.me/busuanzi/2.3/busuanzi.pure.mini.js"></script>
<span id="busuanzi_container_site_pv" style='display:none'>
</br>本站总访问量<span id="busuanzi_value_site_pv"></span>,本站访客数<span id="busuanzi_value_site_uv"></span>,本文总阅读量<span id="busuanzi_value_page_pv"></span>
</span>
<% } %>

修正谷歌搜索

在google.com之前加www

增加百度自定义搜索

在\layout_partial\hearder.ejs中添加代码

1
2
3
4
5
6
7
8
9
<% } else if(theme.baidu_search_my.enable){ %>
<form action="http://www.baidu.com/baidu" method="get" accept-charset="utf-8" class="search">
<label>Search</label>
<input type="search" name="word" maxlength="20" class="search-input" placeholder="<%= __('search') %>">
<input name=tn type=hidden value="bds">
<input name=cl type=hidden value="3">
<input name=ct type=hidden value="2097152">
<input type="hidden" name="si" value="<%- config.url.replace(/^https?:\/\//, '') %>">
</form>

在下面这段代码之前

1
2
3
4
5
6
7
<% } else { %>
<form class="search" action="//www.google.com/search" method="get" accept-charset="utf-8">
<label>Search</label>
<input type="search" id="search" name="q" autocomplete="off" maxlength="20" placeholder="<%= __('search') %>" />
<input type="hidden" name="q" value="site:<%- config.url.replace(/^https?:\/\//, '') %>">
</form>
<% } %>

增加”更新时间”

  • 将\layout_partial\post\hearder.ejs相应代码修改为

    1
    2
    3
    4
    <p class="article-time">
    <time datetime="<%= date_xml(item.date) %>" itemprop="datePublished"> <%= __('datepublished') %> <%= item.date.format(config.datetime_format) %></time>
    <time postupdated="<%= date_xml(item.updated) %>" itemprop="dateModified"> <%= __('dateModified') %> <%= item.updated.format(config.datetime_format) %></time>
    </p>
  • 更改站点配置文件
    time_format: HH:mm:ss下面添加datetime_format: YYYY-MM-DD HH:mm:ss

  • 在语言文件zh-CN.yml中增加dateModified: 更新于
    经测试,文章Front-matter部分也可以不写updated,hexo会自动记录更新时间