Files
HugoBlox-kit/layouts/partials/functions/get_logo.html
T
George Cushen c5b26892a9 feat: add support for SVG logo format + fix logo URL in JSONLD
Can now upload an SVG logo to `assets/images/logo.svg`.

If your site is for an organization, Google currently requires that the logo is PNG rather than SVG otherwise the site may not receive rich search results based on the JSONLD (see https://developers.google.com/search/docs/data-types/logo).

Also, this commit fixes the logo URL in the site's JSONLD metadata - irrespective of the above feature, the logo URL metadata broke when adding the new automated logo detection system in #1439.

Close #1512
Fix #1516
Fix #1439
2020-02-09 00:53:02 +00:00

22 lines
981 B
HTML

{{/* Function to get logo image. */}}
{{/* Inputs: constraint: max_height/fit (str); size (int) */}}
{{/* Output: resource (obj) */}}
{{/* Workaround fact Hugo does not support GetMatch in assets dir */}}
{{/* Hugo doesn't support image ops on SVG: https://discourse.gohugo.io/t/ho-do-i-convert-a-generic-resource-to-image-resource/22570/4 */}}
{{ $logo := resources.Get "images/logo.png" | default (resources.Get "images/logo.svg") }}
{{ $logo_proc := $logo }}
{{/* If the type of image can be resized by Hugo, resize it given a `.size` argument to the function. */}}
{{ if resources.Get "images/logo.png" }}
{{ if eq .constraint "max_height" }}
{{/* Resize logo to fit specified max height. */}}
{{ $logo_proc = ($logo.Resize (printf "x%s" (string .size))) }}
{{ else }}
{{/* Constrain logo to fit within specified dimensions. */}}
{{ $logo_proc = ($logo.Fit (printf "%sx%s" (string .size) (string .size))) }}
{{ end }}
{{ end }}
{{ return $logo_proc }}