最早在China Unix上写博客,后来转战新浪。在azelea的说服下,果断换成wordpress,写技术博客贴点代码什么的,新浪必须是太渣。azelea是我开始独立博客的领路人,为我提供了空间和域名。再后来自己买了空间和ygc.name的域名,用了好几年。本来一直有想法要换成github+jekll,恰巧Wei Shen强力推荐HUGO。于是再一次换博客。

首先面临着wordpress迁移的问题。

导入wordpress posts为markdown文件

试用了多个插件或脚本,都是各种出错。最后发现了神器potter-wordpress,通过npm安装:

npm install -g pottercms-wordpress

然后一个语句:

potter-wordpress -h WORDPRESS_SITE_URL -u USER_NAME -p PASSWORD --dir PATH_TO_STORE_MD_FILES

自动从线上把posts抓下来,并转化为markdown。在之前各种搞不定之后,看到下面的输出有种莫名的快感。

Fetching articles…

   Got : [Sun Nov 29 2015] R kernel in Jupyter notebook 3
   Got : [Mon Nov 09 2015] phylomoji with ggtree
   Got : [Tue Nov 17 2015] 合体中的操作系统
   Got : [Mon Nov 02 2015] Comparison of clusterProfiler and GSEA-P
   Got : [Thu Oct 01 2015] ChIPseq data mining with ChIPseeker
   Got : [Tue Oct 06 2015] TRIE
   Got : [Thu Oct 15 2015] [BioC 3.2] NEWS of my BioC packages
   Got : [Wed Oct 21 2015] use simplify to remove redundancy of enriched GO terms

   ...

   Got : [Mon May 14 2007] Edit partition table in NetBSD/macppc
   Got : [Mon May 14 2007] 我的emacs配置文件
   Got : [Mon May 14 2007] pkgsrc tips
   Got : [Thu May 03 2007] scilab三维平面绘图
   Got : [Sat Jun 24 2006] qvwm窗口管理器的windows2000主题
   Got : [Wed Jun 14 2006] 安装os9和netbsd双系统
   Got : [Sat May 28 2005] 在emacs里使用maxima
   Got : [Mon Mar 14 2005] scau校园网认证
   Got : [Fri Jan 14 2005] Powerbook G3上安装gentoo

Done.

导出wordpress的评论

安装Disqus Comment System plugin, 点击Export comments to Disqus搞定

再到Disqus后台弄迁移,做个域名映射。

安装HUGO

安装hugo对于Mac用户来说,太容易,brew大法搞定。

brew install hugo

MathJax支持

把下面的代码:

<script type="text/javascript"
  src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML">
</script>
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
  tex2jax: {
    inlineMath: [['$','$'], ['\\(','\\)']],
    displayMath: [['$$','$$'], ['\[','\]']],
    processEscapes: true,
    processEnvironments: true,
    skipTags: ['script', 'noscript', 'style', 'textarea', 'pre'],
    TeX: { equationNumbers: { autoNumber: "AMS" },
         extensions: ["AMSmath.js", "AMSsymbols.js"] }
  }
});
</script>

加入主题到文件layouts/partials/foot.html中,就可以实现$\LaTeX$公式的解析。

social网分享

使用ShareThis. 把下面代码加到layouts/post/single.html的适当位置。

<span class='st_twitter_hcount' displayText='Tweet'></span>
<span class='st_facebook_hcount' displayText='Facebook'></span>
<span class='st_sina_hcount' displayText='Sina'></span>
<span class='st_linkedin_hcount' displayText='LinkedIn'></span>

再加script加到layouts/partials/foot.html中。

<script type="text/javascript" src="http://w.sharethis.com/button/buttons.js"></script>
<script type="text/javascript">stLight.options({publisher: "d135f460-3fc5-4802-8169-bd08e4734a09", doNotHash: false, doNotCopy: false, hashAddressBar: false});</script>

代码高亮

加代码到layouts/partials/foot.html中。

<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.1.0/styles/zenburn.min.css">
<script src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.1.0/highlight.min.js"></script>
<script>hljs.initHighlightingOnLoad();</script>

访问统计

以前在wordpress中使用flagcounter,现在发现了RevolverMaps,功能更好,把相应的代码加到sidebar中去即可。2016-03-18开始记录访问。