Hello. I have some error.
+++
mainImg = "https://imgopt.pages.dev/assets/xrpl-grants-crypto-projects_original.jpg"
+++
single.html
{{ $url := "https://imgopt.pages.dev/assets/xrpl-grants-crypto-projects_original.jpg" }}
{{ $url_par := .Params.mainImg }}
{{ with resources.GetRemote $url_par }}
<img
class="object-cover"
src="{{ .Permalink }}"
alt="{{ .Params.altMainImg }}"
title="{{ .Params.titleMainImg }}"
loading="lazy"
decoding="async"
{{/* crossorigin="anonymous"
sizes="(max-width: 768px) 100vw, (max-width: 1024px) 50vw, 33vw"
srcset="small.jpg 500w, medium.jpg 768w, {{ .RelPermalink }} 1024w" */}}
/>
{{ end }}
When I use $url with a string, it works fine, but when I use $url_par, I get an error.
What is .Params.mainImg? Does that value exist on every page?
+++
title = "XRPL Grants Announces Seventh Batch of Selected Projects"
date = 2024-05-22T22:30:34+03:00
draft = false
slug = "xrpl-grants-announces-seventh-batch-of-selected-projects"
tags = ['hot', 'funding', 'grants', 'projects']
[params]
sourse = "Binance"
sourseTitle = "XRPL Grants Announces Seventh Batch of Selected Projects"
sourseUrl = "https://www.binance.com/en/square/post/2024-05-22-xrpl-grants-announces-seventh-batch-of-selected-projects-8442766091162"
imgHost = "https://imgopt.pages.dev/assets/"
mainImg = "https://imgopt.pages.dev/assets/xrpl-grants-crypto-projects_original.jpg"
altMainImg = "Overview of cryptocurrency projects funded by XRPL Grants"
titleMainImg = "XRPL Grants Funding Innovative Crypto Projects"
generatorMainImg = "Bing DALL·E 3"
aimodel = "Claude 3 Sonnet"
exclusive = false
exclusiveRef = ""
+++
Yes. I created new branch, saved and del all content and I have only one post. I changed mainImg with all languages and have an error too
I’m pretty sure you missed something. When a page doesn’t have a mainImg param the value is “”, hence the error. Learn to code defensively:
{{ with .Params.mainImg }}
{{ with resources.GetRemote . }}
{{ end }}
{{ end }}
1 Like
Problem was with empty single.html file in my content when I test theme
I deleted it and code works fine
Regardless, code defensively.
1 Like
system
Closed
9
This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.