With the same code below, hugo server works or not. When I try to start the server, there is error:
executing "partials/post-card.html" at <$src.RelPermalink>: nil pointer evaluating resource.Resource.RelPermalink
but when I remove $src variables, run the server - Hugo started and runs well - then retype the same code below and safe the file, Hugo still runs well. CTRL+F5 in the browser, still Hugo runs well. Then when I want to restart the Hugo server, that error shows up again.
partials/post-card.html
<article class="post-card">
<div class="featured-image">
{{ $src := .Resources.GetMatch .Params.image }}
<a href="{{ .RelPermalink }}" class="card-link" aria-label="{{ .Params.title }}"></a>
<img alt="{{ .Params.title }}" src="{{ $src.RelPermalink }}"/>
</div>
<div class="about-post">
<div class="tags">
{{ with .Params.tags }}
{{- range first 1 . -}}
<a class="tag-wrapper" href="/subject/{{ . | urlize}}/">{{ . }}</a>
{{- end -}}
{{ end }}
<div class="break"></div>
{{ with .Params.tags }}
{{- range first 2 (after 1 . ) }}
<a class="tag-wrapper" href="/subject/{{ . | urlize}}/">{{ . }}</a>
{{- end -}}
{{ end }}
</div>
<h2 class="post-card-title"><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></h2>
<p class="post-summary">{{ .Summary }}</p>
</div>
</article>
the page uses partials/post-card.html:
<section>
<div class="latest-posts-section">
<div class="loop-wrap">
{{- $paginator := .Paginate .RegularPages -}}
{{ if $paginator }}
{{- range $paginator.Pages -}}
{{ partial "post-card.html" . }}
{{ end }}
</div>
<div class="break"></div>
<div class="pagination">
<a href="{{ .RelPermalink }}page/2/" aria-label="Load more" style="display: none;"></a>
<button class="button-primary">Load more</button>
</div>
{{ end }}
</div>
</section>
Hugo on Windows