Skip to content

Commit

Permalink
Add twitter/facebook share hints
Browse files Browse the repository at this point in the history
  • Loading branch information
vgvassilev committed Dec 21, 2024
1 parent f51a2c8 commit cad8f24
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 5 deletions.
2 changes: 1 addition & 1 deletion _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# 'jekyll serve'. If you change this file, please restart the server process.

# Site settings
title: The Allan Lab
title: Compiler Research
email: [email protected]
description: > # this means to ignore newlines until "baseurl:"
Write an awesome description for your new site here. You can edit this
Expand Down
6 changes: 2 additions & 4 deletions _includes/head.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>{% if page.title %}{{ page.title | escape }}{% else %}{{ site.title | escape }}{% endif %}</title>
<meta name="description" content="{% if page.excerpt %}{{ page.excerpt | strip_html | strip_newlines | truncate: 160 }}{% else %}{{ site.description }}{% endif %}">
{% if page.banner_image %}
<meta name="og:image" content="{{ site.url }}{{ site.baseurl }}/{{page.banner_image}}">
{% endif %}
{% include og.html %}

<link rel="stylesheet" href="{{ "/css/main.css" | prepend: site.baseurl | prepend: site.url}}">
<link rel="stylesheet" href="{{ "/css/syntax.css" | prepend: site.baseurl | prepend: site.url}}">
<link rel="canonical" href="{{ page.url | replace:'index.html','' | prepend: site.baseurl | prepend: site.url }}">
Expand Down
51 changes: 51 additions & 0 deletions _includes/og.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<meta name="author" content="{% if page.author %} {{ page.author }} {% else %} Compiler Research Team {% endif %}" />
<meta property="og:url" content="{{ page.url | replace:'index.html','' | prepend: site.baseurl | prepend: site.url }}" />
<meta property="og:title" content="{% if page.title %}{{ page.title | strip_html | strip_newlines | truncate: 160 }}{% else %}{{ site.title }}{% endif %}" />
<meta property="og:description" content="{% if page.excerpt %}{{ page.excerpt | strip_html | strip_newlines | truncate: 160 }}{% else %}{{ site.description }}{% endif %}" />
<meta property="og:locale" content="en_US" />
<meta name="twitter:site" content="" />
<meta name="twitter:description" content="{% if page.excerpt %}{{ page.excerpt | strip_html | strip_newlines | truncate: 160 }}{% else %}{{ site.description }}{% endif %}" />
<meta name="twitter:title" content="{% if page.title %}{{ page.title }}{% else %}{{ site.title }}{% endif %}" />

{% assign type = "website" %}
{% if page.layout == "post" %}
{% assign type = "article" %}
{% endif %}

<meta property="og:type" content="{{ type }}" />
{% if type == "article" %}
<!-- Article specific OG data -->
<meta property="article:published_time" content="{{ page.date }}" />
{% if page.modified %}
<meta property="article:modified_time" content="{{ page.modified }}" />
{% endif %}
<meta property="article:author" content="{{ page.author }}" />
<meta property="article:publisher" content="Compiler Research Team" />
<meta property="article:section" content="{{ page.vertical }}" />
{% for tag in page.categories %}
<meta property="article:tag" content="{{ tag }}" />
{% endfor %}
<meta name="keywords" content="{{ page.categories | join: ', ' }}" />
<meta name="twitter:card" content="summary_large_image" />
<meta name="twitter:creator" content="" />

{% if page.ogimagenull %}
<!-- no og image -->
{% elsif page.banner_image %}
<meta property="og:image" content="{{ page.banner_image }}" />
<meta name="twitter:image" content="{{ page.banner_image }}" />
<meta property="og:image:width" content="600" />
<meta property="og:image:height" content="315" />
{% elsif page.image %}
<meta property="og:image" content="{{ page.image }}" />
<meta name="twitter:image" content="{{ page.image }}" />
{% else %}
{% endif %}

{% else %}
<!-- OG data for non-post pages -->
<meta property="og:type" content="website" />
<meta property="og:image" content="" />
<meta name="twitter:card" content="summary_large_image" />
<meta name="twitter:image" content="" />
{% endif %}

0 comments on commit cad8f24

Please sign in to comment.