Merge pull request #50 from prodingerd/patch-1

Add support for Google Analytics and SEO
This commit is contained in:
Chester How 2018-10-07 19:53:20 +08:00 committed by GitHub
commit 5ba410e27a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 18 additions and 11 deletions

View File

@ -1,4 +1,4 @@
# frozen_string_literal: true
source "https://rubygems.org"
gemspec
gemspec

View File

@ -4,6 +4,9 @@ description: "Minimal Jekyll theme for storytellers"
baseurl: "/tale"
url: "https://chesterhow.github.io"
# Google Analytics
google_analytics: UA—XXXXXXXX-X
# Author
author:
name: Chester How
@ -24,6 +27,7 @@ sass:
plugins:
- jekyll-feed
- jekyll-paginate
- jekyll-seo-tag
# - jemoji #Uncomment this to allow emoji in your post
# Permalinks

6
_includes/analytics.html Normal file
View File

@ -0,0 +1,6 @@
<script>
window.ga=window.ga||function(){(ga.q=ga.q||[]).push(arguments)};ga.l=+new Date;
ga('create', '{{ site.google_analytics }}', 'auto');
ga('send', 'pageview');
</script>
<script async src='https://www.google-analytics.com/analytics.js'></script>

View File

@ -1,17 +1,8 @@
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
{% if page.title == "Home" %}
<meta name="description" content="{{ site.description }}">
{% endif %}
<title>
{% if page.title == "Home" %}
{{ site.title }}
{% else %}
{{ page.title }} &middot; {{ site.title }}
{% endif %}
</title>
{% seo %}
<!-- CSS -->
<link rel="stylesheet" href="{{ "/assets/main.css" | relative_url }}">
@ -24,4 +15,9 @@
<!-- RSS -->
{% feed_meta %}
<!-- Google Analytics-->
{% if site.google_analytics and jekyll.environment == 'production' %}
{% include analytics.html %}
{% endif %}
</head>

View File

@ -15,6 +15,7 @@ Gem::Specification.new do |spec|
spec.add_runtime_dependency "jekyll", "~> 3.6"
spec.add_runtime_dependency "jekyll-paginate", "~> 1.1"
spec.add_runtime_dependency "jekyll-feed", "~> 0.10.0"
spec.add_runtime_dependency "jekyll-seo-tag", "~> 2.5.0"
spec.add_development_dependency "bundler", "~> 1.12"
spec.add_development_dependency "rake", "~> 10.0"