How to have a list page for all tags generated by a certain section? Or the least costly way to do the following


My image src = src="/{{ .Params.banner }}" because all the list pages on my site use relative links for displaying thumbnail images.

Recently I added new section to the site, called news where the frontmatter image URL is an absolute URL.

So the above code renders a broken image src, because of the leading /. It generates instead of just the absolute URL.

So for every tag generated from the news section, I need to use src="{{ .Params.banner }}" (no leading /)

I’m thinking 2 options: Which would be better?

  1. create if possible, a custom list page (not sure where in the template look up order), where every tag generated inside this news section uses a custom list page instead of the default list page?

  2. Use a if/then check to see what section the page belongs to and if news then don’t use /

I am unsure how to do either of them.

The news section has 50,000 pages. So I’m trying to keep the generation cost to a minumum and the more checks there are, the more it slows down.

Please advise. I hope I asked my question well. Thank you.

{{ if isset .Params "news" }}
    <img  data-pagefind-meta="image[data-src]" src="/img/placeholder.png" data-src="{{ .Params.banner }}" class="img-responsive shadow" alt="{{.Title}}" title="{{.Title}}" width="255" height="192"  loading="lazy"/>
{{ else }}
    <img  data-pagefind-meta="image[data-src]" src="/img/placeholder.png" data-src="/{{ .Params.banner }}" class="img-responsive shadow" alt="{{.Title}}" title="{{.Title}}" width="255" height="192"  loading="lazy"/>
{{ end }}

I was not able to figure out a solution to this. So I had to do it like this: I had to regenerate 50,000 markdown files again, and add new front matter, check for it.

I’ve no idea how much this adds to the cost of rendering.

Is there a way to find out not just which template file, but what inside that template file is costing the most ?

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.