Skip to content

Commit 5dfeb5a

Browse files
committed
Add OpenGraph/Twitter meta tags for social media preview
1 parent 8832077 commit 5dfeb5a

File tree

5 files changed

+46
-15
lines changed

5 files changed

+46
-15
lines changed

website/config.toml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
# The URL the site will be built for
77
base_url = "https://godot-rust.github.io"
88

9-
title = "godot-rust: Rust bindings for the Godot game engine"
9+
title = "godot-rust: Rust bindings for Godot game engine"
1010

1111
# Whether to automatically compile all Sass files in the sass directory
1212
compile_sass = false
@@ -70,10 +70,6 @@ title = "Main title"
7070
image = "https://via.placeholder.com/200"
7171
image_alt = "Placeholder text describing the index's image."
7272

73-
[extra.default_author]
74-
name = "John Doe"
75-
avatar = "https://via.placeholder.com/200"
76-
avatar_alt = "Placeholder text describing the default author's avatar."
7773

7874
[extra.links]
7975
github_gdnative = "https://github.com/godot-rust/gdnative"
@@ -92,4 +88,4 @@ favicon_32x32 = "/icons/favicon-32x32.png"
9288
apple_touch_icon = "/icons/apple-touch-icon.png"
9389
android_chrome_512 = "/icons/android-chrome-512x512.png"
9490
android_chrome_192 = "/icons/android-chrome-192x192.png"
95-
manifest = "/icons/site.webmanifest"
91+
manifest = "/icons/site.webmanifest"

website/content/_index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
# License, v. 2.0. If a copy of the MPL was not distributed with this
55
# file, You can obtain one at https://mozilla.org/MPL/2.0/.
66

7-
title = "godot-rust"
8-
description = "Rust bindings for Godot"
7+
title = "Rust bindings for Godot game engine"
8+
description = "godot-rust"
99
template = "home.html"
1010
+++
1111

313 KB
Loading

website/templates/home.html

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,7 @@
1515
<div class="flex items-center flex-col mt-10">
1616
<img src="{{ get_url(path='godot-ferris-2.png') }}" class="logo-center" alt="godot-rust Ferris with stripes">
1717

18-
<div class="logo-title mb-12">
19-
{{ section.title }}
20-
</div>
18+
<div class="logo-title mb-12">godot-rust</div>
2119

2220
<!-- Content -->
2321
<div class="markdown-content">

website/templates/layout.html

Lines changed: 41 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,49 @@
4242
<link id="syntax_highlight" href="#" rel="stylesheet">
4343
#}
4444

45+
{#- Custom variables prefixed with 'c_' -#}
46+
47+
{%- if section -%}
48+
{%- set c_page_title = section.title -%}
49+
{%- elif page -%}
50+
{%- set c_page_title = page.title | replace(from='~', to=' ') -%}
51+
{%- else -%}
52+
{#- Includes 404.html, which has only a 'config' metadata; see __tera_context variable -#}
53+
{%- set c_page_title = config.title -%}
54+
{%- endif -%}
55+
56+
{%- set c_page_summary = 'godot-rust' -%}
57+
{%- set c_page_image = get_url(path='godot-ferris-og-dark.png') -%}
58+
59+
{# Page title #}
4560
<title>
46-
{% block title %}
47-
{{ config.title }}
48-
{% endblock title %}
61+
{%- block title -%}
62+
{{ c_page_title }}
63+
{%- endblock title -%}
4964
</title>
50-
</head>
65+
66+
{#
67+
OpenGraph meta tags for social media preview
68+
Can be tested on https://www.opengraph.xyz or https://metatags.io.
69+
#}
70+
<!-- OpenGraph meta tags for social media preview -->
71+
72+
<!-- Discord, Facebook, etc. -->
73+
<meta property="og:url" content="{{ get_url(path='.') | safe }}">
74+
<meta property="og:type" content="website">
75+
<meta property="og:title" content="{{ c_page_title }}">
76+
<meta property="og:description" content="{{ c_page_summary }}">
77+
<meta property="og:image" content="{{ c_page_image | safe }}">
78+
79+
<!-- Twitter Meta Tags -->
80+
<meta name="twitter:card" content="summary_large_image">
81+
<meta property="twitter:domain" content="godot-rust.github.io">
82+
<meta property="twitter:url" content="{{ get_url(path='.') | safe }}">
83+
<meta name="twitter:title" content="{{ c_page_title }}">
84+
<meta name="twitter:description" content="{{ c_page_summary }}">
85+
<meta name="twitter:image" content="{{ c_page_image | safe }}">
86+
87+
</head>
5188
<body class="body-background dark:body-background flex flex-col h-screen justify-between">
5289
<!---------------------------------------------------------->
5390
<!------------------------- NAVBAR ------------------------->

0 commit comments

Comments
 (0)