Skip to content

Commit 17fa926

Browse files
authored
Merge pull request #216 from justwriteclick/ag-ga
Adds Google Tag
2 parents 59afbb1 + ce9845d commit 17fa926

3 files changed

Lines changed: 129 additions & 3 deletions

File tree

_config.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@ title: Let's Treat Docs Like Code
44
locale: en-US
55
description: Technical documentation with tools and techniques like version control (GitHub) and automation (CICD) with static site generators (SSG) and more.
66
logo: /images/treat-docs-like-code.png
7-
#url: http://127.0.0.1:4000
8-
url: https://www.docslikecode.com
7+
url: http://127.0.0.1:4000
8+
#url: https://www.docslikecode.com
99
theme: jekyll-theme-so-simple
10+
skin: "/assets/css/skins/light.css"
1011
search_full_content: true
1112
tag_archive_path: "/tags/#"
1213
footer_links:
@@ -76,7 +77,7 @@ exclude: ["_drafts", "lib", "config.rb", "Capfile", "config", "log", "Rakefile",
7677

7778
comments: false
7879
twitter: annegentle
79-
google_analytics: UA-85706588-1
80+
google_analytics: G-6MYV72DWCZ
8081

8182
# Site author, previously was site.owner
8283
author:

_includes/head.html

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
<head>
2+
{%- if jekyll.environment == 'production' and site.google_analytics -%}
3+
<!-- Google tag (gtag.js) -->
4+
<script async src="https://www.googletagmanager.com/gtag/js?id={{ site.google_analytics }}"></script>
5+
<script>
6+
window.dataLayer = window.dataLayer || [];
7+
function gtag(){dataLayer.push(arguments);}
8+
gtag('js', new Date());
9+
gtag('config', '{{ site.google_analytics }}');
10+
</script>
11+
{%- endif %}
12+
13+
<meta charset="utf-8">
14+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
15+
<meta name="viewport" content="width=device-width, initial-scale=1">
16+
{% if site.owner.google.verify %}<meta name="google-site-verification" content="{{ site.owner.google.verify }}">{% endif %}
17+
{% if site.owner.bing-verify %}<meta name="msvalidate.01" content="{{ site.owner.bing-verify }}">{% endif %}
18+
19+
{% if site.plugins contains 'jekyll-seo-tag' or site.gems contains 'jekyll-seo-tag' %}
20+
{% comment %}
21+
Add metadata for search engines and social networks if jekyll-seo-tag plugin is enabled
22+
{% endcomment %}
23+
{% include head-seo.html %}
24+
{% else %}
25+
<title>{% if page.title %}{{ page.title | escape }}{% else %}{{ site.title | escape }}{% endif %}</title>
26+
<meta name="description" content="{{ page.excerpt | default: site.description | strip_html | normalize_whitespace | truncate: 160 | escape }}">
27+
<link rel="canonical" href="{{ page.url | replace:'index.html', '' | absolute_url }}">
28+
{% endif %}
29+
30+
<script>
31+
/* Cut the mustard */
32+
if ( 'querySelector' in document && 'addEventListener' in window ) {
33+
document.documentElement.className = document.documentElement.className.replace(/\bno-js\b/g, '') + 'js';
34+
}
35+
</script>
36+
37+
<link rel="stylesheet" href="{{ '/assets/css/main.css' | relative_url }}">
38+
<link rel="stylesheet" href="{{ site.skin | default: '/assets/css/skins/default.css' | relative_url }}">
39+
{% if site.google_fonts %}
40+
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family={%- for font in site.google_fonts -%}{{ font.name | replace: ' ', '+' }}{% if font.weights %}:{% endif %}{{ font.weights | remove: ' ' }}{% if forloop.last != true %}|{% endif %}{%- endfor -%}">
41+
{% endif %}
42+
43+
{%- if site.plugins contains 'jekyll-feed' or site.gems contains 'jekyll-feed' -%}
44+
{%- comment -%}
45+
Add Atom feed link if jekyll-feed plugin is enabled
46+
{%- endcomment -%}
47+
{% include head-feed.html %}
48+
{%- endif -%}
49+
50+
{%- if site.head_scripts -%}
51+
{%- for script in site.head_scripts -%}
52+
{%- if script contains "://" -%}
53+
{%- capture script_path %}{{ script }}{% endcapture -%}
54+
{%- else -%}
55+
{%- capture script_path %}{{ script | absolute_url }}{% endcapture -%}
56+
{%- endif -%}
57+
<script src="{{ script_path }}"></script>
58+
{%- endfor -%}
59+
{%- endif -%}
60+
61+
{% include head-custom.html %}
62+
</head>

_includes/scripts.html

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
{%- if site.footer_scripts -%}
2+
{%- for script in site.footer_scripts -%}
3+
{%- if script contains "://" -%}
4+
{%- capture script_path %}{{ script }}{% endcapture -%}
5+
{%- else -%}
6+
{%- capture script_path %}{{ script | absolute_url }}{% endcapture -%}
7+
{%- endif -%}
8+
<script src="{{ script_path }}"></script>
9+
{%- endfor -%}
10+
{%- else -%}
11+
<script src="https://code.jquery.com/jquery-3.3.1.min.js" integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8=" crossorigin="anonymous"></script>
12+
<script src="{{ '/assets/js/main.min.js' | relative_url }}"></script>
13+
<script src="https://use.fontawesome.com/releases/v5.0.12/js/all.js"></script>
14+
{%- endif -%}
15+
16+
<!-- "Old" Tracking ID with Google Analytics 3
17+
{%- if jekyll.environment == 'production' and site.google_analytics -%}
18+
<script>
19+
if(!(window.doNotTrack === "1" || navigator.doNotTrack === "1" || navigator.doNotTrack === "yes" || navigator.msDoNotTrack === "1")) {
20+
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
21+
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
22+
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
23+
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
24+
ga('create', '{{ site.google_analytics }}', 'auto');
25+
ga('send', 'pageview');
26+
}
27+
</script>
28+
{%- endif %}
29+
-->
30+
{% if site.mathjax == true or site.mathjax.enable == true %}
31+
<!-- MathJax -->
32+
{% capture mathjaxjs %}https://cdn.jsdelivr.net/npm/mathjax@3/es5/{{ site.mathjax.combo | default: "tex-svg" }}.js{% endcapture %}
33+
<script>
34+
// http://docs.mathjax.org/en/latest/upgrading/v2.html
35+
MathJax = {
36+
tex: {
37+
tags: "{{ site.mathjax.tags | default: 'ams' }}" // eq numbering options: none, ams, all
38+
},
39+
options: {
40+
renderActions: {
41+
// for mathjax 3, handle <script "math/tex"> blocks inserted by kramdown
42+
find: [10, function (doc) {
43+
for (const node of document.querySelectorAll('script[type^="math/tex"]')) {
44+
const display = !!node.type.match(/; *mode=display/);
45+
const math = new doc.options.MathItem(node.textContent, doc.inputJax[0], display);
46+
const text = document.createTextNode('');
47+
node.parentNode.replaceChild(text, node);
48+
math.start = {node: text, delim: '', n: 0};
49+
math.end = {node: text, delim: '', n: 0};
50+
doc.math.push(math);
51+
}
52+
}, '']
53+
}
54+
}
55+
}
56+
</script>
57+
58+
<script type="text/javascript" id="MathJax-script" async src="{{ mathjaxjs }}"></script>
59+
{% endif %}
60+
61+
{%- if page.layout == "search" -%}
62+
{% include lunr-search-scripts.html %}
63+
{%- endif -%}

0 commit comments

Comments
 (0)