From 900e683872b38d990c2bcdb54b291f0f331880cc Mon Sep 17 00:00:00 2001 From: MofuMoca Date: Wed, 13 Sep 2023 15:42:46 +0800 Subject: [PATCH] Add og tag option to show site name. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 增加 og tag 可以選擇是否要包含網站名稱,用於某些預覽連結只顯示 og:title 而不顯示 og:site_name 時,可以直接在預覽上查看到網站名稱。 預設為 false,維持原本此 theme 的設定,若需要在本 commit 之中也有設定好 params 設定為 false,在 partials/head/opengraph/provider/base.html 有設定 default 值,以防使用者沒有設定時不會出錯。 Add og tag options to set 'og:title' as 'title - sitename' or just 'Title' for some website link preview just show title not includ sitename. The defautl value is 'false' in example config.yaml and in partials/head/opengraph/provider/base.html set default vaule to 'false' via code. --- config.yaml | 3 +++ layouts/partials/head/opengraph/provider/base.html | 8 +++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/config.yaml b/config.yaml index fafd340..a2febe5 100644 --- a/config.yaml +++ b/config.yaml @@ -115,6 +115,9 @@ params: page: [] opengraph: + # If true,'og:title' will set 'Title - SiteName' else will be just 'Title'. + # If this params not set, default will be 'false'. + title_include_site_name: false twitter: # Your Twitter username site: diff --git a/layouts/partials/head/opengraph/provider/base.html b/layouts/partials/head/opengraph/provider/base.html index 3e51d37..909a4b1 100644 --- a/layouts/partials/head/opengraph/provider/base.html +++ b/layouts/partials/head/opengraph/provider/base.html @@ -1,7 +1,13 @@ {{- $title := partialCached "data/title" . .RelPermalink -}} {{- $description := partialCached "data/description" . .RelPermalink -}} - +