Skip to content

Commit 8f19a47

Browse files
committed
Add google analytics; include social.html
1 parent b3db535 commit 8f19a47

File tree

5 files changed

+49
-21
lines changed

5 files changed

+49
-21
lines changed

_config.yml

+3
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,6 @@ social:
4040
# Toggle link/icon to view atom feed (/atom.xml) in sidebar
4141
show_atom_feed: true
4242

43+
# Google Analytics key, leave blank to ignore
44+
google_analytics_key: UA-100083417-1
45+

_includes/analytics.html

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{% if site.google_analytics_key %}
2+
<script type="text/javascript">
3+
4+
var _gaq = _gaq || [];
5+
_gaq.push(['_setAccount', '{{ site.google_analytics_key }}']);
6+
_gaq.push(['_trackPageview']);
7+
8+
(function() {
9+
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
10+
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
11+
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
12+
})();
13+
14+
</script>
15+
{% endif %}

_includes/sidebar.html

+1-21
Original file line numberDiff line numberDiff line change
@@ -34,27 +34,7 @@ <h1>
3434
<a class="sidebar-nav-item" href="{{ site.github.repo }}">GitHub project</a>
3535
<span class="sidebar-nav-item">Currently v{{ site.version }}</span>
3636

37-
{% if site.social.github %}
38-
<a title="{{ site.social.github }} on Github" href="https://github.com/{{ site.social.github }}"><i class="fa fa-github-square"></i></a>
39-
{% endif %}
40-
{% if site.social.hacker_news %}
41-
<a title="{{ site.social.hacker_news }} on Hacker News" href="https://news.ycombinator.com/user?id={{site.social.hacker_news }}"><i class="fa fa-hacker-news"></i></a>
42-
{% endif %}
43-
{% if site.social.twitter %}
44-
<a title="{{ site.social.twitter }} on Twitter" href="https://twitter.com/{{ site.social.twitter }}"><i class="fa fa-twitter-square"></i></a>
45-
{% endif %}
46-
{% if site.social.facebook %}
47-
<a title="{{ site.author.name }} on Facebook" href="https://facebook.com/{{ site.social.facebook }}"><i class="fa fa-facebook-square"></i></a>
48-
{% endif %}
49-
{% if site.social.linkedin %}
50-
<a title="{{ site.author.name }} on LinkedIn" href="https://www.linkedin.com/in/{{ site.social.linkedin }}"><i class="fa fa-linkedin-square"></i></a>
51-
{% endif %}
52-
{% if site.social.gplus %}
53-
<a title="{{ site.author.name }} on Google Plus" href="https://plus.google.com/{{ site.social.gplus }}"><i class="fa fa-google-plus-square"></i></a>
54-
{% endif %}
55-
{% if site.show_atom_feed %}
56-
<a title="Atom feed" id="atom" href="/atom.xml"><i class="fa fa-rss-square"></i></a>
57-
{% endif %}
37+
{% include social.html %}
5838
</nav>
5939

6040
<p>&copy; {{ site.time | date: '%Y' }}. All rights reserved.</p>

_includes/social.html

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{% if site.social.github %}
2+
<a title="{{ site.social.github }} on Github" href="https://github.com/{{ site.social.github }}"><i class="fa fa-github-square"></i></a>
3+
{% endif %}
4+
5+
{% if site.social.hacker_news %}
6+
<a title="{{ site.social.hacker_news }} on Hacker News" href="https://news.ycombinator.com/user?id={{site.social.hacker_news }}"><i class="fa fa-hacker-news"></i></a>
7+
{% endif %}
8+
9+
{% if site.social.twitter %}
10+
<a title="{{ site.social.twitter }} on Twitter" href="https://twitter.com/{{ site.social.twitter }}"><i class="fa fa-twitter-square"></i></a>
11+
{% endif %}
12+
13+
{% if site.social.facebook %}
14+
<a title="{{ site.author.name }} on Facebook" href="https://facebook.com/{{ site.social.facebook }}"><i class="fa fa-facebook-square"></i></a>
15+
{% endif %}
16+
17+
{% if site.social.linkedin %}
18+
<a title="{{ site.author.name }} on LinkedIn" href="https://www.linkedin.com/in/{{ site.social.linkedin }}"><i class="fa fa-linkedin-square"></i></a>
19+
{% endif %}
20+
21+
{% if site.social.gplus %}
22+
<a title="{{ site.author.name }} on Google Plus" href="https://plus.google.com/{{ site.social.gplus }}"><i class="fa fa-google-plus-square"></i></a>
23+
{% endif %}
24+
25+
{% if site.show_atom_feed %}
26+
<a title="Atom feed" id="atom" href="/atom.xml"><i class="fa fa-rss-square"></i></a>
27+
{% endif %}
28+

_layouts/default.html

+2
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,7 @@
1111
{{ content }}
1212
</div>
1313

14+
{% include analytics.html %}
15+
1416
</body>
1517
</html>

0 commit comments

Comments
 (0)