[outputs]
home = ["HTML", "Search"]
Hi all, I want to include some JS and CSS only on the Search
output (use same baseof.html
), but I couldn’t recognize whether I’m on the search
page, since the .RelPermalink
always return the default format (HTML
) URL.
I’m wondering if it’s safe to use Store
in this case?
// baseof.html
{{ if .Store.Get "search" }}
<link rel="stylesheet" herf="css/search.css">
{{ end }}
{{ block "main" . }}{{ end }}
// index.search.html
{{ define "main" }}
{{ .Store.Set "search" true }}
SEARCH PAGE
{{ end }}
EDITED:
The Store
doesn’t work, there is a workaround that create a duplicate baseof
template named baseof.search.html
, but it’s not a good choice
EDITED #2
There is other workaround by using block
, but it is still a bit complicated.
// baseof.html
<html>
<head>
{{ block "head-end" . }}{{ end }}
</head>
<body>
{{ block "main" . }}{{ end }}
</body>
<html>
// index.search.html
{{ define "head-end" }}
<link rel="stylesheet" herf="css/search.css">
{{ end }}
{{ define "main" }}
SEARCH PAGE
{{ end }}