I presume it’s possible to override Hugo’s built-in internal template[s], but I’m not quite sure where within my theme I would put my custom version, or whether I have to override the entire internal template, or can just override one particular aspect?
To be exact, I’m looking for a way to cutomise the new paginator’s template. I know I can style it up, to a degree, with CSS, but certain visual aspects are hard-wired in to the template_embedded.go file –for example the use of angle brackets << for the first/previous…next/last links:
Just to expand on [bjornerik][1]'s answer [and possibly for my own future reference!]:
I added a “pagination.html” file to my themes layouts > partials directory, containing the meat and potatoes of the approriate function from [template_embedded.go][2]:
{{ $pag := $.Paginator }}
{{ if gt $pag.TotalPages 1 }}
<ul class="pagination">
{{ with $pag.First }}
<li>
<a href="{{ .Url }}" aria-label="First"><span aria-hidden="true">««</span></a>
</li>
{{ end }}
<li
{{ if not $pag.HasPrev }}class="disabled"{{ end }}>
<a href="{{ if $pag.HasPrev }}{{ $pag.Prev.Url }}{{ end }}" aria-label="Previous"><span aria-hidden="true">«</span></a>
</li>
{{ range $pag.Pagers }}
<li
{{ if eq . $pag }}class="active"{{ end }}><a href="{{ .Url }}">{{ .PageNumber }}</a></li>
{{ end }}
<li
{{ if not $pag.HasNext }}class="disabled"{{ end }}>
<a href="{{ if $pag.HasNext }}{{ $pag.Next.Url }}{{ end }}" aria-label="Next"><span aria-hidden="true">»</span></a>
</li>
{{ with $pag.Last }}
<li>
<a href="{{ .Url }}" aria-label="Last"><span aria-hidden="true">»»</span></a>
</li>
{{ end }}
</ul>
{{ end }}
{{"<!-- end pagination partial //-->" | safeHtml}}````
----
and then changed the code in my template's *index.html* from referencing the internal template: `{{ template "_internal/pagination.html" . }}` to reference the new partial instead: `{{ template "theme/partials/pagination.html" . }}`.
Job's a good 'un! Now to start customising....
[1]: http://discuss.gohugo.io/users/bjornerik
[2]: https://github.com/spf13/hugo/blob/master/tpl/template_embedded.go