73f355ce Update theme 83ff50c2 Use example.com in examples 71292134 Add alias news > release-notes 2e15f642 Update theme 8eef09d2 Add Pygments configuration 572b9e75 Clean up the code shortcode use a1b2fd3b Remove the code fence language codes 1473b1d9 Remove redundant text b92c2042 Update theme 8f439c28 Edit contributing section in README 8bcf8a19 Add contributing section to README 4c44ee1c Fix broken content file 2bdc7710 Clarify .Data.Pages sorting in lists.md 092271c2 Use infinitive mood for main titles b9b8abef Update theme to reflect change to home page content b897b71b Change copy to use sentence case fd675ee5 Enable RSS feed for sections 060a5e27 Correct movie title in taxonomies.md 6a5ca96a Update displayed site name for Hub 22f4b7a4 Add example of starting up the local server d9612cb3 Update theme a8c3988a Update theme 4198189d Update theme 12d6b016 Update theme 2b1c4197 Update theme b6d90a1e Fix News release titles cfe751db Add some build info to README git-subtree-dir: docs git-subtree-split: 73f355ce0dd88d032062ea70067431ab980cdd8d
1.8 KiB
date | categories | description | link | title | draft | author | |
---|---|---|---|---|---|---|---|
2017-04-16T13:53:58-04:00 |
|
Hugo 0.20.2 adds support for plain text partials included into HTML templates | Hugo 0.20.2 | false | bep |
Hugo 0.20.2
adds support for plain text partials included into HTML
templates. This was a side-effect of the big new Custom Output Format feature in 0.20
, and while the change was intentional and there was an ongoing discussion about fixing it in #3273, it did break some themes. There were valid workarounds for these themes, but we might as well get it right.
The most obvious use case for this is inline CSS
styles, which you now can do without having to name your partials with a html
suffix.
A simple example:
In layouts/partials/mystyles.css
:
body {
background-color: {{ .Param "colors.main" }}
}
Then in config.toml
(note that by using the .Param
lookup func, we can override the color in a page’s front matter if we want):
[params]
[params.colors]
main = "green"
text = "blue"
And then in layouts/partials/head.html
(or the partial used to include the head section into your layout):
<head>
<style type="text/css">
{{ partial "mystyles.css" . | safeCSS }}
</style>
</head>
Of course, 0.20
also made it super-easy to create external CSS
stylesheets based on your site and page configuration. A simple example:
Add “CSS” to your home page’s outputs
list, create the template /layouts/index.css
using Go template syntax for the dynamic parts, and then include it into your HTML
template with:
{{ with .OutputFormats.Get "css" }}
<link rel="{{ .Rel }}" type="{{ .MediaType.Type }}" href="{{ .Permalink | safeURL }}">
{{ end }}`