Skip to content

Commit 4cf1d83

Browse files
authored
OG meta tags by default (php#1027)
Fix php#981
1 parent d4acbf4 commit 4cf1d83

File tree

2 files changed

+22
-23
lines changed

2 files changed

+22
-23
lines changed

include/layout.inc

+22
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,9 @@ function site_header(string $title = 'Hypertext Preprocessor', array $config = [
424424
{
425425
global $MYSITE;
426426

427+
$meta_image_path = $MYSITE . 'images/meta-image.png';
428+
$meta_description = "PHP is a popular general-purpose scripting language that powers everything from your blog to the most popular websites in the world.";
429+
427430
$defaults = [
428431
"lang" => myphpnet_language(),
429432
"current" => "",
@@ -432,6 +435,25 @@ function site_header(string $title = 'Hypertext Preprocessor', array $config = [
432435
'layout_span' => 9,
433436
"cache" => false,
434437
"headsup" => "",
438+
'meta_tags' => <<<META
439+
<meta name="Description" content="{$meta_description}" />
440+
441+
<meta name="twitter:card" content="summary_large_image" />
442+
<meta name="twitter:site" content="@official_php" />
443+
<meta name="twitter:title" content="PHP: Hypertext Preprocessor" />
444+
<meta name="twitter:description" content="{$meta_description}" />
445+
<meta name="twitter:creator" content="@official_php" />
446+
<meta name="twitter:image:src" content="{$meta_image_path}" />
447+
448+
<meta itemprop="name" content="PHP: Hypertext Preprocessor" />
449+
<meta itemprop="description" content="$meta_description" />
450+
<meta itemprop="image" content="{$meta_image_path}" />
451+
452+
<meta property="og:image" content="{$meta_image_path}" />
453+
<meta property="og:description" content="$meta_description" />
454+
455+
<link href="https://fosstodon.org/@php" rel="me" />
456+
META
435457
];
436458

437459
$config = array_merge($defaults, $config);

index.php

-23
Original file line numberDiff line numberDiff line change
@@ -118,10 +118,6 @@
118118
</div>
119119
EOF;
120120

121-
// Write out common header
122-
$meta_image_path = $MYSITE . 'images/meta-image.png';
123-
$meta_description = "PHP is a popular general-purpose scripting language that powers everything from your blog to the most popular websites in the world.";
124-
125121
site_header("Hypertext Preprocessor",
126122
[
127123
'current' => 'home',
@@ -149,25 +145,6 @@
149145
],
150146
'css' => ['home.css'],
151147
'intro' => $intro,
152-
'meta_tags' => <<<META
153-
<meta name="Description" content="{$meta_description}" />
154-
155-
<meta name="twitter:card" content="summary_large_image" />
156-
<meta name="twitter:site" content="@official_php" />
157-
<meta name="twitter:title" content="PHP: Hypertext Preprocessor" />
158-
<meta name="twitter:description" content="{$meta_description}" />
159-
<meta name="twitter:creator" content="@official_php" />
160-
<meta name="twitter:image:src" content="{$meta_image_path}" />
161-
162-
<meta itemprop="name" content="PHP: Hypertext Preprocessor" />
163-
<meta itemprop="description" content="$meta_description" />
164-
<meta itemprop="image" content="{$meta_image_path}" />
165-
166-
<meta property="og:image" content="{$meta_image_path}" />
167-
<meta property="og:description" content="$meta_description" />
168-
169-
<link href="https://fosstodon.org/@php" rel="me" />
170-
META
171148
],
172149
);
173150

0 commit comments

Comments
 (0)