Skip to content

Commit

Permalink
Add head-custom.html to allow easier customization of the <head>
Browse files Browse the repository at this point in the history
  • Loading branch information
parkr committed Jul 26, 2021
1 parent 6ed8ed0 commit 305d7d6
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 11 deletions.
10 changes: 10 additions & 0 deletions _includes/head-custom-google-analytics.html
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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 -->
12 changes: 1 addition & 11 deletions _layouts/default.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<link rel="stylesheet" type="text/css" media="screen" href="{{ '/assets/css/style.css?v=' | append: site.github.build_revision | relative_url }}">

{% seo %}
{% include head-custom.html %}
</head>

<body>
Expand Down Expand Up @@ -47,16 +48,5 @@ <h2 id="project_tagline">{{ site.description | default: site.github.project_tagl
<p>Published with <a href="https://pages.github.com">GitHub Pages</a></p>
</footer>
</div>

{% 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 %}
</body>
</html>

1 comment on commit 305d7d6

@NiKiZe
Copy link

@NiKiZe NiKiZe commented on 305d7d6 Jan 14, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we have something similar for footer?

Please sign in to comment.