add google anaytics and baidu tongji

feature/cover-image
nodejh 8 years ago
parent 9acf4f3db9
commit 733cd09dea

@ -1,8 +1,10 @@
# Cactus Plus # Cactus Plus
[English Documention](https://github.com/nodejh/hugo-theme-cactus-plus/blob/master/README.md) | [中文文档](https://github.com/nodejh/hugo-theme-cactus-plus/blob/master/README_zh-cn.md) [English Documention](https://github.com/nodejh/hugo-theme-cactus-plus/blob/master/README.md) | [中文文档](https://github.com/nodejh/hugo-theme-cactus-plus/blob/master/README_zh-cn.md)
Cactus Plus is a minimalistic theme for bloggers based on the theme named [Cactus](https://github.com/digitalcraftsman/hugo-cactus-theme). Noteworthy features of this Hugo theme are the integration of a comment-system powered by [Disqus](https://disqus.com/) and [Duoshuo](http://duoshuo.com/), a customizable about page, a simple tags page and a minimalistic archives page, support for RSS feeds, syntax highlighting for source code and sharing options for blog posts.
Cactus Plus is a minimalistic theme for bloggers based on the theme named [Cactus](https://github.com/digitalcraftsman/hugo-cactus-theme). Noteworthy features of this Hugo theme are the integration of a comment-system powered by [Disqus](https://disqus.com/) and [Duoshuo](http://duoshuo.com/), a customizable about page, a simple tags page and a minimalistic archives page, support for RSS feeds, syntax highlighting for source code and site analytics.
## Screenshot ## Screenshot
@ -31,7 +33,7 @@ To use it, copy the [`config.toml`](https://github.com/nodejh/hugo-theme-cactus-
## About page ## About page
Use the about page to introduce yourself to your visitors. You can customize the content as you like in the [`config.toml`](//github.com/digitalcraftsman/hugo-cactus-theme/blob/dev/exampleSite/config.toml). Use the about page to introduce yourself to your visitors. You can customize the content as you like in the `/content/about/index.md`.
## Avatar ## Avatar
@ -56,6 +58,16 @@ This theme features a comment system powered by Duoshuo too. Duoshuo is mainly p
Just set both `enableDisqus = false` and `enableDuoshuo = false` if you want to disable comment. Just set both `enableDisqus = false` and `enableDuoshuo = false` if you want to disable comment.
## Google Analytics
This theme use Google Analytics defalut. If you want to disable Google Analytics, just set `enableGoogleAnalytics = false` in [`config.toml`](https://github.com/nodejh/hugo-theme-cactus-plus/blob/master/exampleSite/config.toml).
## 百度统计
This theme alse features Baidu Tongji for Chinese users. To use Baidu Tongji you should set `enableBaiduAnalytics = true` and set `baiduAnalytics` to your `Baidu Tongji Code` which looks like `39843ea392201290bd6f76173d2e0000` in [`config.toml`](https://github.com/nodejh/hugo-theme-cactus-plus/blob/master/exampleSite/config.toml).
## Social link icons ## Social link icons
You can add a social link panel in the footer by adding entries to the `social` block in the [`config.toml`](https://github.com/nodejh/hugo-theme-cactus-plus/blob/master/exampleSite/config.toml). You can choose between two icon fonts: You can add a social link panel in the footer by adding entries to the `social` block in the [`config.toml`](https://github.com/nodejh/hugo-theme-cactus-plus/blob/master/exampleSite/config.toml). You can choose between two icon fonts:
@ -65,11 +77,14 @@ You can add a social link panel in the footer by adding entries to the `social`
Assign either `font-awesome` or `mono-social` to the `iconFont` variable. The Mono social icons offer three styles of icons: -circle, rounded, or default (empty). Assign either `font-awesome` or `mono-social` to the `iconFont` variable. The Mono social icons offer three styles of icons: -circle, rounded, or default (empty).
## Nearly finished ## Nearly finished
In order to see your site in action, run Hugo's built-in local server. In order to see your site in action, run Hugo's built-in local server.
$ hugo server ```
$ hugo server
```
Now enter [`localhost:1313`](http://localhost:1313) in the address bar of your browser. Now enter [`localhost:1313`](http://localhost:1313) in the address bar of your browser.

@ -3,13 +3,15 @@
[English Documention](https://github.com/nodejh/hugo-theme-cactus-plus/blob/master/README.md) | [中文文档](https://github.com/nodejh/hugo-theme-cactus-plus/blob/master/README_zh-cn.md) [English Documention](https://github.com/nodejh/hugo-theme-cactus-plus/blob/master/README.md) | [中文文档](https://github.com/nodejh/hugo-theme-cactus-plus/blob/master/README_zh-cn.md)
Cactus Plus 是一个根据 [Cactus](https://github.com/digitalcraftsman/hugo-cactus-theme) 改编的简约主题。我在 [Cactus](https://github.com/digitalcraftsman/hugo-cactus-theme)的基础上做了一些修改,主要是添加了归档页、添加了标签页、修改了部分样式。总的来说该主题具有以下特点: Cactus Plus 是一个根据 [Cactus](https://github.com/digitalcraftsman/hugo-cactus-theme) 改编的简约主题。我在 [Cactus](https://github.com/digitalcraftsman/hugo-cactus-theme)的基础上做了一些修改,主要是添加了归档页和标签页、添加了百度统计、修改了部分样式。总的来说该主题具有以下特点:
+ 自定义关于页面 + 自定义关于页面
+ 标签页 + 标签页
+ 归档页 + 归档页
+ Disqus 评论 + Disqus 评论
+ 多说评论 + 多说评论
+ Google Analytics
+ 百度统计
+ RSS 订阅 + RSS 订阅
+ 语法高亮 + 语法高亮
@ -83,6 +85,15 @@ $ git clone https://github.com/nodejh/hugo-theme-cactus-plus.git
然后我的博客由于同步到了 Github Issues所以也同时在主题中提供了跳转到 Github Issues 评论的文字提示。只需要设置 `enableGithubIssuesTips = true` 即可。当然,一般是不需要这么做的,这可能只是我个人需求。具体效果可以参考我的博客 [http://nodejh.com](http://nodejh.com)。 然后我的博客由于同步到了 Github Issues所以也同时在主题中提供了跳转到 Github Issues 评论的文字提示。只需要设置 `enableGithubIssuesTips = true` 即可。当然,一般是不需要这么做的,这可能只是我个人需求。具体效果可以参考我的博客 [http://nodejh.com](http://nodejh.com)。
## Google Analytics
该主题默认使用了 Google Analytics。如果要禁用 Google Analytics只需要设置 [`config.toml`](https://github.com/nodejh/hugo-theme-cactus-plus/blob/master/exampleSite/config.toml) 中的 `enableGoogleAnalytics = false`
## 百度统计
该主题同样也提供了百度统计,主要是方便中国大陆用户使用。开启百度统计的方式,首先需要设置 [`config.toml`](https://github.com/nodejh/hugo-theme-cactus-plus/blob/master/exampleSite/config.toml) 中的 `enableBaiduAnalytics = true`,然后将 `baiduAnalytics` 改为在百度统计后台获取的 `统计代码`,形如 `39843ea392201290bd6f76173d2e0000`
## 社交链接 ## 社交链接
本主题的社交链接是字体图标的样式,并放置在了页面底部。你可以通过在 `config.toml``social` 模块中修改添加你的社交链接。社交链接提供了两种字体图标,选用其中一种即可: 本主题的社交链接是字体图标的样式,并放置在了页面底部。你可以通过在 `config.toml``social` 模块中修改添加你的社交链接。社交链接提供了两种字体图标,选用其中一种即可:

@ -1,4 +1,4 @@
<script src="https://code.jquery.com/jquery-2.2.4.js" integrity="sha256-iT6Q9iMJYuQiMWNd9lDyBUStIq/8PuOW33aOqmvFpqI=" crossorigin="anonymous"></script> <script src="https://code.jquery.com/jquery-2.2.4.js"></script>
<script src="{{ .Site.BaseURL }}js/main.js"></script> <script src="{{ .Site.BaseURL }}js/main.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.7.0/highlight.min.js"></script> <script src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.7.0/highlight.min.js"></script>
<script>hljs.initHighlightingOnLoad();</script> <script>hljs.initHighlightingOnLoad();</script>
@ -7,12 +7,19 @@
<script src="{{ $.Site.BaseURL }}{{ . }}"></script> <script src="{{ $.Site.BaseURL }}{{ . }}"></script>
{{ end }} {{ end }}
{{ if .Site.Params.enableGoogleAnalytics }}
{{ template "_internal/google_analytics.html" . }}
{{ end }}
{{ if .Site.Params.enableBaiduAnalytics }}
<script> <script>
var baiduAnalytics = '{{ .Site.Params.baiduAnalytics }}';
var _hmt = _hmt || []; var _hmt = _hmt || [];
(function() { (function() {
var hm = document.createElement("script"); var hm = document.createElement("script");
hm.src = "https://hm.baidu.com/hm.js?39843ea392201290bd6f76173d2e1633"; hm.src = "https://hm.baidu.com/hm.js?" + baiduAnalytics;
var s = document.getElementsByTagName("script")[0]; var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(hm, s); s.parentNode.insertBefore(hm, s);
})(); })();
</script> </script>
{{ end }}

Loading…
Cancel
Save