Add local extension to header partial

I have a use case where I would like to add custom content before the `</head>` tag. This change implements that. Users can add locally (either in their overriding theme or in the root directory) add /layouts/partials/overrides/header.html and the content is printed at that location.

I see multiple uses for this, after `<body>`, before `</body>`... The path in templates.Exists must be run through printf for some reason.
This commit is contained in:
Patrick Kollitsch 2020-09-21 19:02:43 +07:00 committed by GitHub
parent 88e31c87a8
commit a77c08dbf5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -49,5 +49,11 @@
<script src="{{ `plugins/match-height/jquery.matchHeight-min.js` | absURL }}"></script>
{{ template "_internal/google_analytics.html" . }}
{{ if templates.Exists ( printf "partials/overrides/header.html" ) }}
{{ partial "partials/overrides/header.html" . }}
{{ else }}
{{ "<!-- create /layouts/partials/overrides/header.html in your own theme or root directory to add your custom content here -->" | safeHTML }}
{{ end }}
</head>
</head>