瀏覽代碼

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 年之前
父節點
當前提交
c463ad7d90
共有 5 個文件被更改,包括 9 次插入5 次删除
  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 查看文件

@@ -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 查看文件

@@ -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 查看文件

@@ -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 查看文件

@@ -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 查看文件

@@ -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…
取消
儲存