Skip to content

Commit 674b2da

Browse files
authored
Merge pull request ResearchObject#481 from elichad/improve-page-metadata
Improve page metadata handling for better SEO and thumbnail rendering in chats
2 parents c2ca9bd + 0c477dd commit 674b2da

File tree

1 file changed

+15
-11
lines changed

1 file changed

+15
-11
lines changed

docs/_includes/head.html

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
11
<head>
2-
<meta charset="utf-8">
3-
<meta http-equiv="X-UA-Compatible" content="IE=edge">
4-
<meta name="viewport" content="width=device-width, initial-scale=1">
5-
<meta name="description" content="{% if page.description %}{{ page.description | strip_html | strip_newlines | truncate: 160 }}{% else %}{{ site.description }}{% endif %}">
62
{%- capture keywords %}
73
{%- if page.related_pages %}
84
{%- for section in page.related_pages %}
@@ -19,20 +15,28 @@
1915
{%- endfor %}{{allkeywords}}
2016
{%- endif %}
2117
{%- endcapture %}
18+
{%- if page.type %}
19+
{%- assign subtitle = page.type | replace: "_", " " %}
20+
{%- endif %}
21+
{%- capture title %}{% if page.url == "/" %}{{site.title}}{% elsif page.title %}{% if subtitle %}{{subtitle}}: {% endif %}{{ page.title }} | {{ site.title }}{%- else %}{{ site.title }}{% endif %}{% endcapture %}
22+
{%- capture description %}{% if page.url == "/" %}{{site.description}}{% elsif page.description %}{{ page.description | strip_html | replace: '\n', ' ' | truncatewords: 30, '...' }}{% elsif page.summary %}{{ page.summary | strip_html | replace: '\n', ' ' | truncatewords: 30, '...' }}{% else %}{{ page.content | strip_html | replace: '\n', ' ' | truncatewords: 30, '...' }}{% endif %}{% endcapture %}
23+
<meta charset="utf-8">
24+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
25+
<title>{{title}}</title>
26+
<meta name="viewport" content="width=device-width, initial-scale=1">
27+
<meta name="description" content="{{description}}">
2228
<meta name="keywords" content="{{keywords}}">
23-
<meta property="og:title" content="{{ site.title }}" />
24-
<meta property="og:description" content="{{ site.description }}" />
29+
<meta property="og:title" content="{{title}}" />
30+
<meta property="og:description" content="{{description}}" />
31+
<meta property="og:type" content="article">
32+
<meta property="og:url" content="{{ page.url | absolute_url }}">
2533
<meta property="og:image" content="//{{site.github.url | remove: 'https://' | remove: 'http://'}}/assets/img/apple-touch-icon.png" />
26-
<meta name="apple-mobile-web-app-title" content="{{site.title}}">
34+
<meta name="apple-mobile-web-app-title" content="{{title}}">
2735
<meta name="msapplication-TileColor" content="#{{site.theme_variables.theme_color | default: 0d6efd }}">
2836
<meta name="theme-color" content="#{{site.theme_variables.theme_color | default: 0d6efd }}">
2937
{%- if page.no_robots %}
3038
<meta name="robots" content="noindex" />
3139
{%- endif %}
32-
{%- if page.type %}
33-
{%- assign subtitle = page.type | replace: "_", " " | capitalize %}
34-
{%- endif %}
35-
<title>{% if page.title %}{% if subtitle %}{{subtitle}}: {% endif %}{{ page.title }} | {{ site.title }}{%- else %}{{ site.title }}{% endif %}</title>
3640
<!-- Syntax highlighting -->
3741
<link rel="stylesheet" href="{{ 'assets/css/syntax.css' | relative_url }}">
3842
<!-- Country flags -->

0 commit comments

Comments
 (0)