Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Blog twittercard sharing #2970

Merged
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions _data/post_categories.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
categories:
- name: default-category
image: https://opensearch.org/assets/media/blog-category-images/OpenSearch_WebGraphic_Generic-01.png
secondary: https://opensearch.org/assets/media/blog-category-images/OpenSearch_WebGraphic_Generic-02.png
- name: technical-posts
image: https://opensearch.org/assets/media/blog-category-images/OpenSearch_WebGraphic_Technical-01.png
secondary: https://opensearch.org/assets/media/blog-category-images/OpenSearch_WebGraphic_Technical-02.png
# image: http://127.0.0.1:4000/assets/media/blog-category-images/OpenSearch_WebGraphic_Technical-01.png #for local testing
- name: community
image: https://opensearch.org/assets/media/blog-category-images/OpenSearch_WebGraphic_Community-01.png
secondary: https://opensearch.org/assets/media/blog-category-images/OpenSearch_WebGraphic_Community-02.png
- name: releases
image: https://opensearch.org/assets/media/blog-category-images/OpenSearch_WebGraphic_Release-01.png
secondary: https://opensearch.org/assets/media/blog-category-images/OpenSearch_WebGraphic_Release-02.png
- name: partners
image: ""
- name: feature
image: ""
- name: intro
image: ""
- name: community-updates
image: ""
- name: events
image: ""
- name: odfe-updates
image: ""
129 changes: 129 additions & 0 deletions _includes/head-twitter-metatags.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
{% feed_meta %} <!-- The {% feed_meta %} is a Liquid tag used in Jekyll to generate meta tags for RSS and Atom feeds. It is typically used in the head section of a website to provide metadata for feed readers and social media platforms. The {% feed_meta %} tag generates the necessary meta tags based on the configuration specified in the _config.yml file. -->
{% assign pagetitle = page.title | strip_newlines %}
<title>{% if pagetitle != "" %} {{ page.title | append: " &middot;" }} {% endif %} OpenSearch</title>
<link rel="stylesheet" href="{{'assets/css/output.css' | relative_url }}" >
{% if page.has_science_table %}
{%- include science-table-styles.html -%}
{% endif %}




{% assign meta_keywords = page.meta_keywords | default: "open-source, search, opensearch" %}
{% assign meta_description = page.excerpt | default:page.description | default:page.meta_description | default: "OpenSearch is a community-driven, Apache 2.0-licensed open source search and analytics suite that makes it easy to ingest, search, visualize, and analyze data." %}
{% assign twitter_card_type = "summary_large_image" %}
{% assign twitter_card_title = page.title | default: "OpenSearch"%}
{% assign OpenSearch_twitter_account = "@OpenSearchProj" %}


<!-- LOGIC to pull the correct category image onto blog posts that do not have an image -->
{% if page.featured_image %}
{% assign twitter_card_image = page.featured_image %}

{% else %}
<!-- If there is a category, pull the correct category and fetch the generic image for that category -->
{% if page.categories %}
{% assign category = page.categories | first %}
{% else %}
<!-- If there is no category, give the page the gerneric category "default-category" -->
{% assign category = "default-category" %}
{% endif %}

{% assign category_image = "" %}

<!-- Fetch the generic image for the pages category -->
{% for cat in site.data.post_categories.categories %}
{% if cat.name == category %}
{% assign category_image = cat.image %}
{% endif %}
{% endfor %}



<!-- does that category have an image? if yes assign the image, otherwise default to a normal summary card and no image. -->
{% if category_image %}
{% assign twitter_card_image = category_image %}

<!-- if there is no category image... assign the default image -->
{% else %}
{% assign twitter_card_image = "/assets/img/opensearch-twitter-card.png" %}

{% endif %}

{% endif %}


<meta name="ROBOTS" content="ALL" />
<meta name="MSSmartTagsPreventParsing" content="true" /> <!-- MSSmartTags... turns off internet explorer smart tags that are outdated and no longer supported. -->
<meta name="msapplication-TileColor" content="#113228">
<meta name="msapplication-TileImage" content="{{'img/icon-tile.png' | relative_url }}">

<!-- TWITTER -->
<meta name="twitter:title" content="{{ twitter_card_title }}" />
<meta name="twitter:card" content="{{ twitter_card_type }}" />
<meta name="twitter:description" content="{{ meta_description | xml_escape }}" />
<meta name="twitter:image" content="{{ twitter_card_image }}" />
<meta name="twitter:site" content="{{ OpenSearch_twitter_account }}" />

<!-- OG: OPENGRAPH SHARING -->
<meta property="og:image" content="{{ twitter_card_image }}" />
<meta property="og:image:type" content="image/png" />
<meta property="og:image:height" content="1200" />
<meta property="og:image:width" content="675" />
<meta property="og:description" content="{{ meta_description | xml_escape }}" />
<meta property="og:type" content="website" />
<meta property="og:url" content="{{ page.url | absolute_url }}" />
<meta property="og:title" content="{{ twitter_card_title }}" />
<meta property="og:site_name" content="{{ site.title }}" />





<!-- TESTING -->
<meta name="post category" content="{{ category }}" />
<meta name="category image" content="{{ category_image }}" />
<meta name="twitter_card_image" content="{{ twitter_card_image }}" />
<meta name="keywords" content="{{ meta_keywords }}" />
<meta name="description" content="{{ meta_description }}" />



{% if page.authors %}
{% assign author_short_name = page.authors | first %}
{% assign author = site.community_members | where: 'short_name', author_short_name | first %}
{% if author.twitter %}
<meta name="twitter:creator" content="@{{ author.twitter }}" />
{% endif %}
{% endif %}



<!-- Favicons -->
{{ page.link_rel_tags }}
<link rel="apple-touch-icon" href="{{'assets/img/apple-touch-icon.png' | relative_url }}">
<link rel="icon" sizes="192x192" href="{{'assets/img/apple-touch-icon.png' | relative_url }}">
<link rel="shortcut icon" href="{{'assets/img/favicon.ico' | relative_url }}">
<link rel="canonical" href="{%if page.canonical %}{{page.canonical}}{%else%}{{site.url | append: page.url}}{%endif%}" />




<script src="{{ 'assets/js/lib/modernizr.js' | relative_url }}"></script>
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-BQV14XK08F"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-BQV14XK08F');
</script>

{{ page.head_extra }}

</head>

119 changes: 35 additions & 84 deletions _includes/head.html
Original file line number Diff line number Diff line change
@@ -1,85 +1,36 @@
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="ROBOTS" content="ALL" />
<meta name="MSSmartTagsPreventParsing" content="true" />
<meta name="Copyright" content="" />

<meta name="keywords" content="
{% if page.meta_keywords %}
{{ page.meta_keywords }}
{% else %}
open-source, search, opensearch
{% endif %}"
/>

{% feed_meta %}

{% if page.meta_description %}<meta name="description" content="{{ page.meta_description }}" />{%endif%}

{% assign pagetitle = page.title | strip_newlines %}

<meta name="twitter:card" content="summary" />
<meta name="twitter:title" content="{% if pagetitle != "" %}{{ page.title }}{% else %}OpenSearch{% endif %}" />
{% if page.twittercard.account %}
<meta name="twitter:site" content="{{ page.twittercard.account }}" />
{% elsif page.authors %}
{% assign author_short_name = page.authors | first %}
{% assign author = site.community_members | where: 'short_name', author_short_name | first %}
{% if author.twitter %}
<meta name="twitter:site" content="@{{ author.twitter }}" />
{% endif %}
{% endif %}



{% if page.twittercard.description %}
<meta name="twitter:description" content="{{ page.twittercard.description | xml_escape }}" />
{% else %}
<meta name="twitter:description" content="OpenSearch is a community-driven, Apache 2.0-licensed open source search and analytics suite that makes it easy to ingest, search, visualize, and analyze data." />
{% endif %}
{% if page.twittercard.image %}
<meta name="twitter:image" content="{{ page.twittercard.image }}" />
{% else %}
<meta name="twitter:image" content="https://opensearch.org/assets/opensearch-twitter-card.png" />
{% endif %}


<meta content="{{ site.title }}" property="og:site_name">
<meta content="{{ page.url | absolute_url }}" property="og:url">
{% if page.title %}<meta content="{{ page.title }}" property="og:title">
{% else %}<meta content="{{ site.title }}" property="og:title"> {% endif %}

{% if page.image %}<meta content="{{ site.url }}/assets/img/posts/{{ page.image }}" property="og:image">
{% else %}<meta content="{{ site.url }}/assets/img/logo-high-resolution.png" property="og:image">{% endif %}

{{ page.link_rel_tags }}
<!-- Favicons -->
<link rel="apple-touch-icon" href="{{'assets/img/apple-touch-icon.png' | relative_url }}">
<link rel="icon" sizes="192x192" href="{{'assets/img/apple-touch-icon.png' | relative_url }}">
<link rel="shortcut icon" href="{{'assets/img/favicon.ico' | relative_url }}">

<link rel="canonical" href="{%if page.canonical %}{{page.canonical}}{%else%}{{site.url | append: page.url}}{%endif%}" />

<meta name="msapplication-TileColor" content="#113228">
<meta name="msapplication-TileImage" content="{{'img/icon-tile.png' | relative_url }}">


<title>{% if pagetitle != "" %} {{ page.title | append: " &middot;" }} {% endif %} OpenSearch</title>

<link rel="stylesheet" href="{{'assets/css/output.css' | relative_url }}" >
{% if page.has_science_table %}
{%- include science-table-styles.html -%}
{% endif %}
<script src="{{ 'assets/js/lib/modernizr.js' | relative_url }}"></script>
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-BQV14XK08F"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-BQV14XK08F');
</script>
{{ page.head_extra }}
</head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">

{% feed_meta %}
{% assign pagetitle = page.title | strip_newlines %}
{%- include head-twitter-metatags.html -%}

<title>{% if pagetitle != "" %} {{ page.title | append: " &middot;" }} {% endif %} OpenSearch</title>

<!-- Favicons -->
{{ page.link_rel_tags }}
<link rel="apple-touch-icon" href="{{'assets/img/apple-touch-icon.png' | relative_url }}">
<link rel="icon" sizes="192x192" href="{{'assets/img/apple-touch-icon.png' | relative_url }}">
<link rel="shortcut icon" href="{{'assets/img/favicon.ico' | relative_url }}">
<link rel="canonical" href="{%if page.canonical %}{{page.canonical}}{%else%}{{site.url | append: page.url}}{%endif%}" />

<meta name="msapplication-TileColor" content="#113228">
<meta name="msapplication-TileImage" content="{{'img/icon-tile.png' | relative_url }}">

<link rel="stylesheet" href="{{'assets/css/output.css' | relative_url }}" >
{% if page.has_science_table %}
{%- include science-table-styles.html -%}
{% endif %}
<script src="{{ 'assets/js/lib/modernizr.js' | relative_url }}"></script>
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-BQV14XK08F"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-BQV14XK08F');
</script>
{{ page.head_extra }}
</head>
3 changes: 2 additions & 1 deletion _layouts/default.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@
---
<!DOCTYPE html>
<html lang="{{ page.lang | default: site.lang | default: "en" }}">
{%- include head.html -%}

{% if page.layout == 'post' %}
{% assign page_type_class = 'page--blog-post' %}
{% else %}
{% assign page_type_class = '' %}
{% endif %}

{%- include head.html -%}

<body id="{{ page.sectionid }}" class="{{ page.body_class }} {{ page_type_class }}">
{%- include header.html -%}

Expand Down
1 change: 1 addition & 0 deletions _layouts/post.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
has_science_table: false
primary_link_url: /blog
---

{% assign primary_title = site.headings.news %}
{% assign layout_class = 'sidebar-right' %}
{% capture content %}
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes.