Skip to content

Commit

Permalink
Merge pull request #119 from pages-themes/head-custom
Browse files Browse the repository at this point in the history
Add head-custom.html to allow easier customization of the <head>
  • Loading branch information
parkr committed Jul 26, 2021
2 parents 8a104fd + cb5da9f commit 84cd748
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 11 deletions.
10 changes: 10 additions & 0 deletions _includes/head-custom-google-analytics.html
@@ -0,0 +1,10 @@
{% if site.google_analytics %}
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', '{{ site.google_analytics }}', 'auto');
ga('send', 'pageview');
</script>
{% endif %}
9 changes: 9 additions & 0 deletions _includes/head-custom.html
@@ -0,0 +1,9 @@
<!-- start custom head snippets, customize with your own _includes/head-custom.html file -->

<!-- Setup Google Analytics -->
{% include head-custom-google-analytics.html %}

<!-- You can set your favicon here -->
<!-- link rel="shortcut icon" type="image/x-icon" href="{{ '/favicon.ico' | relative_url }}" -->

<!-- end custom head snippets -->
13 changes: 2 additions & 11 deletions _layouts/default.html
Expand Up @@ -10,12 +10,13 @@
<!--[if lt IE 9]>
<script src="https://cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv.min.js"></script>
<![endif]-->
{% include head-custom.html %}
</head>
<body>
<div class="wrapper">
<header>
<h1><a href="{{ "/" | absolute_url }}">{{ site.title | default: site.github.repository_name }}</a></h1>

{% if site.logo %}
<img src="{{site.logo | relative_url}}" alt="Logo" />
{% endif %}
Expand Down Expand Up @@ -51,15 +52,5 @@ <h1><a href="{{ "/" | absolute_url }}">{{ site.title | default: site.github.repo
</footer>
</div>
<script src="{{ "/assets/js/scale.fix.js" | relative_url }}"></script>
{% if site.google_analytics %}
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
ga('create', '{{ site.google_analytics }}', 'auto');
ga('send', 'pageview');
</script>
{% endif %}
</body>
</html>

0 comments on commit 84cd748

Please sign in to comment.