Skip to content

Commit 2f96786

Browse files
authored
Merge pull request #133 from pages-themes/head-custom
Add head-custom.html to allow easier customization of the <head>
2 parents dfb16f0 + 40f8f3d commit 2f96786

File tree

3 files changed

+20
-10
lines changed

3 files changed

+20
-10
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{% if site.google_analytics %}
2+
<script>
3+
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
4+
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
5+
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
6+
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
7+
ga('create', '{{ site.google_analytics }}', 'auto');
8+
ga('send', 'pageview');
9+
</script>
10+
{% endif %}

_includes/head-custom.html

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<!-- start custom head snippets, customize with your own _includes/head-custom.html file -->
2+
3+
<!-- Setup Google Analytics -->
4+
{% include head-custom-google-analytics.html %}
5+
6+
<!-- You can set your favicon here -->
7+
<!-- link rel="shortcut icon" type="image/x-icon" href="{{ '/favicon.ico' | relative_url }}" -->
8+
9+
<!-- end custom head snippets -->

_layouts/default.html

+1-10
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,6 @@
11
<!DOCTYPE html>
22
<html lang="{{ site.lang | default: "en-US" }}">
33
<head>
4-
5-
{% if site.google_analytics %}
6-
<script async src="https://www.googletagmanager.com/gtag/js?id={{ site.google_analytics }}"></script>
7-
<script>
8-
window.dataLayer = window.dataLayer || [];
9-
function gtag(){dataLayer.push(arguments);}
10-
gtag('js', new Date());
11-
gtag('config', '{{ site.google_analytics }}');
12-
</script>
13-
{% endif %}
144
<meta charset="UTF-8">
155

166
{% seo %}
@@ -20,6 +10,7 @@
2010
<meta name="theme-color" content="#157878">
2111
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
2212
<link rel="stylesheet" href="{{ '/assets/css/style.css?v=' | append: site.github.build_revision | relative_url }}">
13+
{% include head-custom.html %}
2314
</head>
2415
<body>
2516
<a id="skip-to-content" href="#content">Skip to the content.</a>

0 commit comments

Comments
 (0)