Can featured image come from a URL? #880
Replies: 2 comments
-
hello i find a way to use publicly picture , you can add and you need copy blowfish theme's one directory to you site's directory and this is the {{ $disableImageOptimization := .Page.Site.Params.disableImageOptimization | default false }}
{{ with .Params.externalUrl }}
<a href="{{ . }}" target="_blank" rel="external" class="min-w-full">
{{ else }}
<a href="{{ .RelPermalink }}" class="min-w-full">
{{ end }}
<div class="min-h-full border border-neutral-200 dark:border-neutral-700 border-2 rounded overflow-hidden shadow-2xl relative backdrop-blur">
{{ if .Params.ccoverimage }}
<div class="w-full thumbnail_card nozoom" style="background-image:url({{ .Params.ccoverimage }});"></div>
{{ end }}
{{ if and .Draft .Site.Params.article.showDraftLabel }}
<span class="absolute top-0 right-0 m-2">
{{ partial "badge.html" (i18n "article.draft" | emojify) }}
</span>
{{ end }}
<div class="px-6 py-4">
{{ with .Params.externalUrl }}
<div>
<div
class="font-bold text-xl text-neutral-800 decoration-primary-500 hover:underline hover:underline-offset-2 dark:text-neutral">
{{ $.Title | emojify }}
<span class="text-xs align-top cursor-default text-neutral-400 dark:text-neutral-500">
<span class="rtl:hidden">↗</span>
<span class="ltr:hidden">↖</span>
</span>
</div>
</div>
{{ else }}
<div class="font-bold text-xl text-neutral-800 decoration-primary-500 hover:underline hover:underline-offset-2 dark:text-neutral"
href="{{ .RelPermalink }}">{{ .Title | emojify }}</div>
{{ end }}
<div class="text-sm text-neutral-500 dark:text-neutral-400">
{{ partial "article-meta/basic.html" . }}
</div>
{{ if .Params.showSummary | default (.Site.Params.list.showSummary | default false) }}
<div class="py-1 prose dark:prose-invert">
{{ .Summary | emojify }}
</div>
{{ end }}
</div>
<div class="px-6 pt-4 pb-2">
</div>
</div>
</a> this is the {{ $disableImageOptimization := .Page.Site.Params.disableImageOptimization | default false }}
{{ with .Params.externalUrl }}
<a href="{{ . }}" target="_blank" rel="external" class="min-w-full">
{{ else }}
<a href="{{ .RelPermalink }}" class="min-w-full">
{{ end }}
<div class="min-h-full border border-neutral-200 dark:border-neutral-700 border-2 rounded overflow-hidden shadow-2xl relative backdrop-blur">
{{ if .Params.ccoverimage }}
<div class="w-full thumbnail_card nozoom" style="background-image:url({{ .Params.ccoverimage }});"></div>
{{ end }}
{{ if and .Draft .Site.Params.article.showDraftLabel }}
<span class="absolute top-0 right-0 m-2">
{{ partial "badge.html" (i18n "article.draft" | emojify) }}
</span>
{{ end }}
<div class="px-6 py-4">
{{ with .Params.externalUrl }}
<div>
<div
class="font-bold text-xl text-neutral-800 decoration-primary-500 hover:underline hover:underline-offset-2 dark:text-neutral">
{{ $.Title | emojify }}
<span class="text-xs align-top cursor-default text-neutral-400 dark:text-neutral-500">
<span class="rtl:hidden">↗</span>
<span class="ltr:hidden">↖</span>
</span>
</div>
</div>
{{ else }}
<div class="font-bold text-xl text-neutral-800 decoration-primary-500 hover:underline hover:underline-offset-2 dark:text-neutral"
href="{{ .RelPermalink }}">{{ .Title | emojify }}</div>
{{ end }}
<div class="text-sm text-neutral-500 dark:text-neutral-400">
{{ partial "article-meta/basic.html" . }}
</div>
{{ if .Params.showSummary | default (.Site.Params.list.showSummary | default false) }}
<div class="py-1 prose dark:prose-invert">
{{ .Summary | emojify }}
</div>
{{ end }}
</div>
<div class="px-6 pt-4 pb-2">
</div>
</div>
</a> |
Beta Was this translation helpful? Give feedback.
-
you might want to wrap that differently. check out the hugo docs for 'resources.GetRemote'..
and can then eval scratch.Get 'source' later in yer template to optionally preset the asset. https://gohugo.io/content-management/image-processing/#remote-resource https://cloudcannon.com/tutorials/hugo-and-remote-data-files/ |
Beta Was this translation helpful? Give feedback.
-
I would like to use a publicly available image as the featured image for an article.
Instead of having a local file
featured.png
, can I reference a URL instead?I know there's
externalURL
frontmatter parameter from https://blowfish.page/samples/external/, I am wondering if I can do something similar forfeatured.png
Beta Was this translation helpful? Give feedback.
All reactions