Added links and seo

This commit is contained in:
elvistony 2023-08-05 20:19:31 +01:00
parent b50df3a682
commit c861cd6e30
3 changed files with 134 additions and 3 deletions

124
_includes/seo.html Normal file
View file

@ -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: '<br />', ' ' | 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 -%}
<title>{{ 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 %}</title>
<meta name="description" content="{{ seo_description }}">
{% if author.name %}
<meta name="author" content="{{ author.name | default: author }}">
{% if og_type == "article" %}<meta property="article:author" content="{{ author.name | default: author }}">{% endif %}{% endif %}
<meta property="og:type" content="{{ og_type }}">
<meta property="og:locale" content="{{ site.locale | replace: "-", "_" | default: "en_US" }}">
<meta property="og:site_name" content="{{ site.title }}">
<meta property="og:title" content="{{ page.title | default: site.title | markdownify | strip_html | strip_newlines | escape_once }}">
<meta property="og:url" content="{{ canonical_url }}">
{% if seo_description %}<meta property="og:description" content="{{ seo_description }}">{% endif %}
{% if page_large_image %}
<meta property="og:image" content="{{ page_large_image }}">
{% elsif page_teaser_image %}
<meta property="og:image" content="{{ page_teaser_image }}">
{% endif %}
{% if site.twitter.username %}
<meta name="twitter:site" content="@{{ site.twitter.username | replace: "@", "" }}">
<meta name="twitter:title" content="{{ page.title | default: site.title | markdownify | strip_html | strip_newlines | escape_once }}">
<meta name="twitter:description" content="{{ seo_description }}">
<meta name="twitter:url" content="{{ canonical_url }}">
{% if page_large_image %}
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:image" content="{{ page_large_image }}">
{% else %}
<meta name="twitter:card" content="summary">
{% if page_teaser_image %}
<meta name="twitter:image" content="{{ page_teaser_image }}">
{% endif %}
{% endif %}
{% if author_twitter %}
<meta name="twitter:creator" content="@{{ author_twitter }}">
{% endif %}
{% endif %}
{% if page.date %}
<meta property="article:published_time" content="{{ page.date | date_to_xmlschema }}">
{% endif %}
{% if og_type == "article" and page.last_modified_at %}
<meta property="article:modified_time" content="{{ page.last_modified_at | date_to_xmlschema }}">
{% endif %}
{% if site.facebook %}
{% if site.facebook.publisher %}
<meta property="article:publisher" content="{{ site.facebook.publisher }}">
{% endif %}
{% if site.facebook.app_id %}
<meta property="fb:app_id" content="{{ site.facebook.app_id }}">
{% endif %}
{% endif %}
<link rel="canonical" href="{{ canonical_url }}">
{% if paginator.previous_page %}
<link rel="prev" href="{{ paginator.previous_page_path | absolute_url }}">
{% endif %}
{% if paginator.next_page %}
<link rel="next" href="{{ paginator.next_page_path | absolute_url }}">
{% endif %}
<script type="application/ld+json">
{
"@context": "https://schema.org",
{% if site.social.type == "Organization" %}
"@type": "Organization",
"url": {{ '/' | absolute_url | jsonify }}{% if site.og_image %},
"logo": {{ site_og_image | jsonify }}{% endif %}
{% else %}
"@type": "Person",
"name": {{ site.social.name | default: site.name | jsonify }},
"url": {{ '/' | absolute_url |jsonify }}{% if site.social.links %},
"sameAs": {{ site.social.links | jsonify }}{% endif %}
{% endif %}
}
</script>
{% if site.google_site_verification %}
<meta name="google-site-verification" content="{{ site.google_site_verification }}" />
{% endif %}
{% if site.bing_site_verification %}
<meta name="msvalidate.01" content="{{ site.bing_site_verification }}">
{% endif %}
{% if site.alexa_site_verification %}
<meta name="alexaVerifyID" content="{{ site.alexa_site_verification }}">
{% endif %}
{% if site.yandex_site_verification %}
<meta name="yandex-verification" content="{{ site.yandex_site_verification }}">
{% endif %}
{% if site.naver_site_verification %}
<meta name="naver-site-verification" content="{{ site.naver_site_verification }}">
{% endif %}
{% if site.baidu_site_verification %}
<meta name="baidu-site-verification" content="{{ site.baidu_site_verification }}">
{% endif %}

View file

@ -5,7 +5,11 @@
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link rel="icon" href="{{ site.baseurl }}/{{site.favicon}}">
<title>{{ page.title }} | {{site.title}}</title>
{% if page.permalink== "/" %}
<title>{{site.title}}</title>
{% else %}
<title>{{ page.title }} | {{site.title}}</title>
{% endif %}
{% seo %}
@ -15,7 +19,10 @@
<link href="{{ site.baseurl }}/assets/css/custom.css" rel="stylesheet">
<!-- custom CSS end-->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.2/css/all.min.css" integrity="sha512-z3gLpd7yknf1YoNbCzqRKc4qyor8gaKU1qmn+CShxbuBusANI9QpRohGBreCFkKxLhei6S9CQXFEbbKuqLg0DA==" crossorigin="anonymous" referrerpolicy="no-referrer" />
{% include seo.html %}
<link rel="icon" href="/assets/images/favicon.png">
{% if jekyll.environment == "production" %}
<!-- Global site tag (gtag.js) - Google Analytics -->
<!-- <script async src="https://www.googletagmanager.com/gtag/js?id={{site.ganalytics}}"></script>

View file

@ -16,7 +16,7 @@ permalink: /
<p class="lead mb-4 text-white">Our bright & creative ninjas have created masterpieces that are showcased here.</p>
<p class="text-white">
Haven't Heard about Code Ninjas? </br>
<a href="https://codeninjasuk.github.io" class="btn btn-light px-5 btn-lg">Learn more</a>
<a href="https://codeninjaslangley.co.uk" class="btn btn-light px-5 btn-lg">Learn more</a>
</p>
</div>