Skip to content

Commit

Permalink
Merge pull request #112 from boynux/feature/add-custom-js
Browse files Browse the repository at this point in the history
[feature] Add feature to include additional JS to header
  • Loading branch information
daviddarnes authored Nov 11, 2018
2 parents 4169222 + f7d3850 commit 30d1dc8
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 0 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,11 @@ Example usage: `{% include site-search.html %}`

This include has no options. This include will add a block of javascript to the page and javascript reference in order for the search field to work correctly.

### `site-before-start.html` & `site-before-end.html`
Optional html includes for adding scripts, css, js or any embed code you wish to add to every page without the need to overwrite the entire `default.html` template.

**Example usage:** These are different to other includes as they are designed to be overwritten. If you create a `site-before-start.html` file in the `_includes/` the contents of the file will be included just before the closing `</head>` tag. If you create a `site-before-end.html` file the contents of the file will be included just before the closing `</body>` tag.

## Page layouts

As well as `page`, `post`, `blog`, there are a few alternative layouts that can be used on pages:
Expand Down
1 change: 1 addition & 0 deletions _includes/site-before-end.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<!-- Overwrite this file with code you want before the closing </body> tag -->
1 change: 1 addition & 0 deletions _includes/site-before-start.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<!-- Overwrite this file with code you want before the closing </head> tag -->
4 changes: 4 additions & 0 deletions _layouts/default.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
{% if site.avatarurl %}{% include site-favicons.html %}{% endif %}

{% if site.google_analytics %}{% include site-analytics.html %}{% endif %}

{% include site-before-start.html %}
</head>

<body class="layout-{{ page.layout }}{% if page.title %} {{ page.title | slugify }}{% endif %}">
Expand All @@ -41,6 +43,8 @@
{{ content }}

{% if site.service_worker != false %}{% include site-sw.html %}{% endif %}

{% include site-before-end.html %}
</body>

</html>

0 comments on commit 30d1dc8

Please sign in to comment.