Here is the refactor I came up with:
TL;DR of this topic: I’ve been using an unintended feature from the old templating engine, that has been “fixed” in v0.146.0, hence it outputs a blank site.
I have refactored my layouts folder like this:
layouts
├── _partials
│ ├── list.html
│ └── single.html
├── red-style
│ ├── list.html
│ └── single.html
├── green-style
│ ├── list.html
│ └── single.html
├── baseof.html
├── list.html
└── single.html
layout/baseof.html
While layouts/baseof.html has my main html, theme specific parts are marked as a block, something like this:
{{ block "style" .}}
{{ $sass := resources.Get "/scss/main_blue.scss"}}
{{ $style := $sass | css.Sass }}
<link rel="stylesheet" href="{{ $style.Permalink }}" />
{{ end }}
{{ block "main" .}}
{{ end }}
green-style/list.html
Now in the green-style page path, I can redefine the block with my main_green.scss:
{{ define "style" }}
{{ $sass := resources.Get "/scss/main_green.scss" }}
{{ $style := $sass | css.Sass }}
<link rel="stylesheet" href="{{ $style.Permalink }}" />
{{ end }}
_partials/list.html
But now I have a duplicate list.html and single.html in root, green, red and any future page paths that I want to add.
And for that I extract all my list and single specific code as partials, in this case
layouts/_partials/list.html and layouts/_partials/single.html:
<section>
<article>
<p>My cool list!</p>
</article>
<sections>
Redefining everywhere
Now I can add this partial in every list template and just changing the partial will update the layouts in all page paths while keeping the specific list.html code relatively short:
root/baseof.html
{{ block "style" .}}
{{ $sass := resources.Get "/scss/main_blue.scss"}}
{{ $style := $sass | css.Sass }}
<link rel="stylesheet" href="{{ $style.Permalink }}" />
{{ end }}
{{ block "main" .}}
{{ end }}
root/list.html
{{define "main"}}
{{ partial "list.html" .}}
{{end}}
green-style/list.html
{{ define "style" }}
{{ $sass := resources.Get "/scss/main_green.scss" }}
{{ $style := $sass | css.Sass }}
<link rel="stylesheet" href="{{ $style.Permalink }}" />
{{ end }}
{{define "main"}}
{{ partial "list.html" .}}
{{end}}
red-style/list.html
{{ define "style" }}
{{ $sass := resources.Get "/scss/main_red.scss" }}
{{ $style := $sass | css.Sass }}
<link rel="stylesheet" href="{{ $style.Permalink }}" />
{{ end }}
{{define "main"}}
{{ partial "list.html" .}}
{{end}}
root/_partials/list.html
<section>
<article>
<p>My cool list!</p>
</article>
<sections>
If I have to change something in the list, I use _partials/list.html, if I add a new page path like yellow-style I can just copy the list.html and single.html to the new folder and just change the css for the new style!
Where there is a will, there is a way
All of this can be found on my repo with “red-style” being named “tas-battle” and “green-style” being named “tas-comp”