Browse Source

Standardise image_filename page param to image; use for post type as well as image type

Used for og:image meta tag
master
Adrian Short 6 years ago
parent
commit
c463ad7d90
5 changed files with 9 additions and 5 deletions
  1. +3
    -1
      README.md
  2. +2
    -2
      archetypes/images.md
  3. +2
    -0
      archetypes/posts.md
  4. +1
    -1
      layouts/partials/header.html
  5. +1
    -1
      layouts/partials/image.html

+ 3
- 1
README.md View File

@@ -48,7 +48,7 @@ A single image with an optional caption (the `title`) and body text.

# hugo new images/my-image-title.md
Then copy the image file itself to `/static/images/` and update `image_filename` in the front matter if required.
Then copy the image file itself to `/static/images/` and update `image` in the front matter if required.

Set `show_title: true` to display the `title` as a caption beneath the image.

@@ -57,6 +57,8 @@ Set `show_title: true` to display the `title` as a caption beneath the image.
A traditional blog post with mandatory title and body text.

$ hugo new posts/my-post-title.md
Use the `image` field in the front matter to set the featured image for your post. This currently is only shown in the OpenGraph metadata, not on your site itself. If you want an image to show in the list views on your site, put it at the top of your post.

### Quotes



+ 2
- 2
archetypes/images.md View File

@@ -3,8 +3,8 @@ title: "{{ replace .TranslationBaseName "-" " " | title }}"
date: {{ .Date }}
draft: false
type: image
# image_filename is relative to /static/images/
image_filename: {{ .TranslationBaseName }}.jpg
# image is relative to /static/images/
image: {{ .TranslationBaseName }}.jpg
show_title: false
tags:
---

+ 2
- 0
archetypes/posts.md View File

@@ -2,6 +2,8 @@
title: "{{ replace .TranslationBaseName "-" " " | title }}"
date: {{ .Date }}
draft: true
# image is relative to /static/images/
image: {{ .TranslationBaseName }}.jpg
type: post
tags:
---


+ 1
- 1
layouts/partials/header.html View File

@@ -9,7 +9,7 @@
<link rel="alternate" type="application/rss+xml" title="{{ partial "data/title" . }}"
href="{{ .RSSLink }}">
{{- template "_internal/opengraph.html" . -}}
{{ with .Params.image_filename }}
{{ with .Params.image }}
<meta name="og:image" content="{{ "/images/" | absURL }}{{ .}}">
{{ end }}
{{- template "_internal/twitter_cards.html" -}}


+ 1
- 1
layouts/partials/image.html View File

@@ -1,6 +1,6 @@
<figure>
<a href="{{ .Permalink | relURL }}">
<img src="{{ relURL "/images/" }}{{ .Params.image_filename }}" alt="{{ .Params.title }}">
<img src="{{ relURL "/images/" }}{{ .Params.image }}" alt="{{ .Params.title }}">
</a>
{{ if .Params.show_title }}
{{ with .Params.title }}<figcaption>{{ . }}</figcaption>{{ end }}


Loading…
Cancel
Save