From c861cd6e30fa1e1d83c99e9309191890d1b3a679 Mon Sep 17 00:00:00 2001 From: elvistony Date: Sat, 5 Aug 2023 20:19:31 +0100 Subject: [PATCH] Added links and seo --- _includes/seo.html | 124 ++++++++++++++++++++++++++++++++++++++++++ _layouts/default.html | 11 +++- index.html | 2 +- 3 files changed, 134 insertions(+), 3 deletions(-) create mode 100644 _includes/seo.html diff --git a/_includes/seo.html b/_includes/seo.html new file mode 100644 index 0000000..8f03ca0 --- /dev/null +++ b/_includes/seo.html @@ -0,0 +1,124 @@ +{%- if site.url -%} +{%- assign seo_url = site.url | append: site.baseurl -%} +{%- endif -%} +{%- assign seo_url = seo_url | default: site.github.url -%} +{% assign title_separator = site.title_separator | default: '-' | replace: '|', '|' %} +{%- if page.title -%} +{%- assign seo_title = page.title | append: " " | append: title_separator | append: " " | append: site.title -%} +{%- endif -%} +{%- if seo_title -%} +{%- assign seo_title = seo_title | markdownify | strip_html | strip_newlines | escape_once -%} +{%- endif -%} +{% if page.canonical_url %} +{%- assign canonical_url = page.canonical_url %} +{% else %} +{%- assign canonical_url = page.url | replace: "index.html", "" | absolute_url %} +{% endif %} +{%- assign seo_description = page.description | default: page.excerpt | default: site.description -%} +{%- if seo_description -%} +{%- assign seo_description = seo_description | markdownify | strip_html | newline_to_br | strip_newlines | replace: '
', ' ' | escape_once | strip -%} +{%- endif -%} +{%- assign author = page.author | default: page.authors[0] | default: site.author -%} +{%- assign author = site.data.authors[author] | default: author -%} +{%- if author.twitter -%} +{%- assign author_twitter = author.twitter | replace: "@", "" -%} +{%- endif -%} +{%- assign page_large_image = page.header.og_image | default: page.header.overlay_image | default: page.header.image | absolute_url -%} +{%- assign page_large_image = page_large_image | escape -%} +{%- assign page_teaser_image = page.header.teaser | default: site.og_image | absolute_url -%} +{%- assign page_teaser_image = page_teaser_image | escape -%} +{%- assign site_og_image = site.og_image | absolute_url -%} +{%- assign site_og_image = site_og_image | escape -%} +{%- if page.date -%} +{%- assign og_type = "article" -%} +{%- else -%} +{%- assign og_type = "website" -%} +{%- endif -%} +{{ seo_title | default: site.title }}{% if paginator %}{% unless paginator.page == 1 %} {{ title_separator }} {{ site.data.ui-text[site.locale].page | default: "Page" }} {{ paginator.page }}{% endunless %}{% endif %} + +{% if author.name %} + +{% if og_type == "article" %}{% endif %}{% endif %} + + + + + +{% if seo_description %}{% endif %} +{% if page_large_image %} + +{% elsif page_teaser_image %} + +{% endif %} +{% if site.twitter.username %} + + + + + {% if page_large_image %} + + + {% else %} + + {% if page_teaser_image %} + + {% endif %} + {% endif %} + {% if author_twitter %} + + {% endif %} +{% endif %} +{% if page.date %} + +{% endif %} +{% if og_type == "article" and page.last_modified_at %} + +{% endif %} +{% if site.facebook %} + {% if site.facebook.publisher %} + + {% endif %} + {% if site.facebook.app_id %} + + {% endif %} +{% endif %} + +{% if paginator.previous_page %} + +{% endif %} +{% if paginator.next_page %} + +{% endif %} + +{% if site.google_site_verification %} + +{% endif %} +{% if site.bing_site_verification %} + +{% endif %} +{% if site.alexa_site_verification %} + +{% endif %} +{% if site.yandex_site_verification %} + +{% endif %} +{% if site.naver_site_verification %} + +{% endif %} +{% if site.baidu_site_verification %} + +{% endif %} diff --git a/_layouts/default.html b/_layouts/default.html index dca4e28..6013202 100644 --- a/_layouts/default.html +++ b/_layouts/default.html @@ -5,7 +5,11 @@ -{{ page.title }} | {{site.title}} +{% if page.permalink== "/" %} +{{site.title}} +{% else %} + {{ page.title }} | {{site.title}} +{% endif %} {% seo %} @@ -15,7 +19,10 @@ - +{% include seo.html %} + + + {% if jekyll.environment == "production" %}