From b8d1bcd3dea0abd1afef7ef154a4501fbb18938d Mon Sep 17 00:00:00 2001 From: Cotes Chung <11371340+cotes2020@users.noreply.github.com> Date: Wed, 16 Mar 2022 19:43:23 +0800 Subject: [PATCH 1/5] fix: resume the preview image SEO tag (#529) Fix #529 --- _includes/head.html | 25 ++++++++++++++++++++++++- _layouts/post.html | 4 ++-- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/_includes/head.html b/_includes/head.html index 50e0214..948c4f8 100644 --- a/_includes/head.html +++ b/_includes/head.html @@ -23,7 +23,30 @@ {% endif %} - {% seo title=false %} + {% capture seo_tags %} + {% seo title=false %} + {% endcapture %} + + {% if site.img_cdn and seo_tags contains 'og:image' %} + {% assign properties = 'og:image,twitter:image' | split: ',' %} + + {% for prop in properties %} + {% if site.img_cdn contains '//' %} + + {% capture target %} Date: Wed, 16 Mar 2022 19:49:14 +0800 Subject: [PATCH 2/5] fix: when the `site.img_cdn` is set to the local path, the preview-image path loses the `baseurl` --- _includes/refactor-content.html | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/_includes/refactor-content.html b/_includes/refactor-content.html index 6db8923..dd09205 100644 --- a/_includes/refactor-content.html +++ b/_includes/refactor-content.html @@ -92,7 +92,11 @@ {% if site.img_cdn %} - {% assign _src_prefix = site.img_cdn %} + {% if site.img_cdn contains '//' %} + {% assign _src_prefix = site.img_cdn %} + {% else %} + {% assign _src_prefix = site.img_cdn | relative_url %} + {% endif %} {% else %} {% assign _src_prefix = site.baseurl %} {% endif %} From 67d51d5df2ad258aeeec6a99e6d41e42592a14cb Mon Sep 17 00:00:00 2001 From: Cotes Chung <11371340+cotes2020@users.noreply.github.com> Date: Wed, 16 Mar 2022 19:49:57 +0800 Subject: [PATCH 3/5] docs: update preview image's font-matter --- _posts/2019-08-08-text-and-typography.md | 2 +- _posts/2019-08-08-write-a-new-post.md | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/_posts/2019-08-08-text-and-typography.md b/_posts/2019-08-08-text-and-typography.md index cf38af4..23f7c03 100644 --- a/_posts/2019-08-08-text-and-typography.md +++ b/_posts/2019-08-08-text-and-typography.md @@ -9,7 +9,7 @@ tags: [typography] math: true mermaid: true image: - src: /commons/devices-mockup.png + path: /commons/devices-mockup.png width: 800 height: 500 --- diff --git a/_posts/2019-08-08-write-a-new-post.md b/_posts/2019-08-08-write-a-new-post.md index c52c2f1..4696e31 100644 --- a/_posts/2019-08-08-write-a-new-post.md +++ b/_posts/2019-08-08-write-a-new-post.md @@ -221,12 +221,12 @@ The output will be: ### Preview Image -If you want to add an image to the top of the post contents, specify the attribute `src`, `width`, `height`, and `alt` for the image: +If you want to add an image to the top of the post contents, specify the attribute `path`, `width`, `height`, and `alt` for the image: ```yaml --- image: - src: /path/to/image/file + path: /path/to/image/file width: 1000 # in pixels height: 400 # in pixels alt: image alternative text @@ -235,7 +235,7 @@ image: Except for `alt`, all other options are necessary, especially the `width` and `height`, which are related to user experience and web page loading performance. The above section "[Size](#size)" also mentions this. -Starting from _Chirpy v5.0.0_, the attributes `height` and `width` can be abbreviated: `height` → `h`, `width` → `w`. In addition, the [`img_path`](#image-path) can also be passed to the preview image, that is, when it has been set, the attribute `src` only needs the image file name. +Starting from _Chirpy v5.0.0_, the attributes `height` and `width` can be abbreviated: `height` → `h`, `width` → `w`. In addition, the [`img_path`](#image-path) can also be passed to the preview image, that is, when it has been set, the attribute `path` only needs the image file name. ## Pinned Posts From 96a16c868ede51e7dfa412de63ffa1e5a49add7f Mon Sep 17 00:00:00 2001 From: Cotes Chung <11371340+cotes2020@users.noreply.github.com> Date: Thu, 17 Mar 2022 00:29:00 +0800 Subject: [PATCH 4/5] fix: correct the `twitter:creator` of Twitter summary card --- _data/authors.yml | 17 +++++++++++++++++ _layouts/post.html | 6 +++--- 2 files changed, 20 insertions(+), 3 deletions(-) create mode 100644 _data/authors.yml diff --git a/_data/authors.yml b/_data/authors.yml new file mode 100644 index 0000000..f012012 --- /dev/null +++ b/_data/authors.yml @@ -0,0 +1,17 @@ +## Template › https://github.com/jekyll/jekyll-seo-tag/blob/master/docs/advanced-usage.md#setting-author-url +# ------------------------------------- +# {author_id}: +# name: {full name} +# twitter: {twitter_of_author} +# url: {homepage_of_author} +# ------------------------------------- + +cotes: + name: Cotes Chung + twitter: cotes2020 + url: https://github.com/cotes2020/ + +sille_bille: + name: Dinesh Prasanth Moluguwan Krishnamoorthy + twitter: dinesh_MKD + url: https://github.com/SilleBille/ diff --git a/_layouts/post.html b/_layouts/post.html index 48e1d75..e571d71 100644 --- a/_layouts/post.html +++ b/_layouts/post.html @@ -37,11 +37,11 @@ tail_includes:
- {% capture author_name %}{{ page.author.name | default: site.social.name }}{% endcapture %} + {% capture author_name %}{{ site.data.authors[page.author].name | default: site.social.name }}{% endcapture %} {% assign author_link = nil %} - {% if page.author.link %} - {% assign author_link = page.author.link %} + {% if page.author %} + {% assign author_link = site.data.authors[page.author].url %} {% elsif author_name == site.social.name %} {% assign author_link = site.social.links[0] %} {% endif %} From f581b4395fa5a61b4dd922573bfa32a3f9ee8bb3 Mon Sep 17 00:00:00 2001 From: Cotes Chung <11371340+cotes2020@users.noreply.github.com> Date: Thu, 17 Mar 2022 02:05:45 +0800 Subject: [PATCH 5/5] docs: update posts for author info --- _posts/2019-08-08-text-and-typography.md | 4 +--- _posts/2019-08-08-write-a-new-post.md | 23 ++++++++++++++++------ _posts/2019-08-09-getting-started.md | 4 +--- _posts/2019-08-11-customize-the-favicon.md | 4 +--- _posts/2021-01-03-enable-google-pv.md | 4 +--- 5 files changed, 21 insertions(+), 18 deletions(-) diff --git a/_posts/2019-08-08-text-and-typography.md b/_posts/2019-08-08-text-and-typography.md index 23f7c03..736cc97 100644 --- a/_posts/2019-08-08-text-and-typography.md +++ b/_posts/2019-08-08-text-and-typography.md @@ -1,8 +1,6 @@ --- title: Text and Typography -author: - name: Cotes Chung - link: https://github.com/cotes2020 +author: cotes date: 2019-08-08 11:33:00 +0800 categories: [Blogging, Demo] tags: [typography] diff --git a/_posts/2019-08-08-write-a-new-post.md b/_posts/2019-08-08-write-a-new-post.md index 4696e31..3e9d141 100644 --- a/_posts/2019-08-08-write-a-new-post.md +++ b/_posts/2019-08-08-write-a-new-post.md @@ -1,8 +1,6 @@ --- title: Writing a New Post -author: - name: Cotes Chung - link: https://github.com/cotes2020 +author: cotes date: 2019-08-08 14:10:00 +0800 categories: [Blogging, Tutorial] tags: [writing] @@ -50,14 +48,27 @@ tags: [bee] The author information of the post usually does not need to be filled in the _Front Matter_ , they will be obtained from variables `social.name` and the first entry of `social.links` of the configuration file by default. But you can also override it as follows: +Add author information in `_data/authors.yml` (If your website doesn't have this file, don't hesitate to create one.) + +```yaml +: + name: + twitter: + url: +``` +{: file="_data/authors.yml" } + +And then set up the custom author in the post's YAML block: + ```yaml --- -author: - name: Full Name - link: https://example.com +author: --- ``` +> Another benefit of reading the author information from the file `_data/authors.yml`{: .filepath } is that the page will have the meta tag `twitter:creator`, which enriches the [Twitter Cards](https://developer.twitter.com/en/docs/twitter-for-websites/cards/guides/getting-started#card-and-content-attribution) and is good for SEO. +{: .prompt-info } + ## Table of Contents By default, the **T**able **o**f **C**ontents (TOC) is displayed on the right panel of the post. If you want to turn it off globally, go to `_config.yml`{: .filepath} and set the value of variable `toc` to `false`. If you want to turn off TOC for a specific post, add the following to the post's [Front Matter](https://jekyllrb.com/docs/front-matter/): diff --git a/_posts/2019-08-09-getting-started.md b/_posts/2019-08-09-getting-started.md index fbc9510..4febf04 100644 --- a/_posts/2019-08-09-getting-started.md +++ b/_posts/2019-08-09-getting-started.md @@ -1,8 +1,6 @@ --- title: Getting Started -author: - name: Cotes Chung - link: https://github.com/cotes2020 +author: cotes date: 2019-08-09 20:55:00 +0800 categories: [Blogging, Tutorial] tags: [getting started] diff --git a/_posts/2019-08-11-customize-the-favicon.md b/_posts/2019-08-11-customize-the-favicon.md index d936178..6a3e2da 100644 --- a/_posts/2019-08-11-customize-the-favicon.md +++ b/_posts/2019-08-11-customize-the-favicon.md @@ -1,8 +1,6 @@ --- title: Customize the Favicon -author: - name: Cotes Chung - link: https://github.com/cotes2020 +author: cotes date: 2019-08-11 00:34:00 +0800 categories: [Blogging, Tutorial] tags: [favicon] diff --git a/_posts/2021-01-03-enable-google-pv.md b/_posts/2021-01-03-enable-google-pv.md index 9545b33..c5ff4dc 100644 --- a/_posts/2021-01-03-enable-google-pv.md +++ b/_posts/2021-01-03-enable-google-pv.md @@ -1,8 +1,6 @@ --- title: Enable Google Page Views -author: - name: Dinesh Prasanth Moluguwan Krishnamoorthy - link: https://github.com/SilleBille +author: sille_bille date: 2021-01-03 18:32:00 -0500 categories: [Blogging, Tutorial] tags: [google analytics, pageviews]