[web-php] better-embed-cards-and-meta-information: Update title and descriptions for manual pages
| From: | Derick Rethans | Date: | Mon, 01 Sep 2025 10:32:54 +0000 |
| Subject: | [web-php] better-embed-cards-and-meta-information: Update title and descriptions for manual pages | ||
| Groups: | php.webmaster | ||
| Request: | Send a blank email to php-webmaster+get-33147@lists.php.net to get a copy of this message | ||
Author: Derick Rethans (derickr)
Date: 2025-08-28T18:54:57+01:00
Commit: https://github.com/php/web-php/commit/3dfeed6f0658f9cd1fedc8846d1d91c678fd1110
Raw diff: https://github.com/php/web-php/commit/3dfeed6f0658f9cd1fedc8846d1d91c678fd1110.diff
Update title and descriptions for manual pages
This makes use of the new information that Phd will display once
https://github.com/php/phd/pull/201 is merged.
It changes the title on the home page also to just "PHP" (removing the `:
Hypertext Preprocessor` part).
It also changes the meta information for manual pages, which is used for social
media cards.
Changed paths:
M include/header.inc
M include/layout.inc
M include/shared-manual.inc
M index.php
Diff:
diff --git a/include/header.inc b/include/header.inc
index 3da277344c..f3889daf7f 100644
--- a/include/header.inc
+++ b/include/header.inc
@@ -65,7 +65,7 @@ if (!isset($config["languages"])) {
<base href="<?php echo $_SERVER["BASE_HREF"]; ?>">
<?php endif ?>
- <title>PHP: <?php echo $title ?></title>
+ <title><?php echo $title ?></title>
<?php foreach($CSS as $filename => $modified): ?>
<link rel="stylesheet" type="text/css" href="/cached.php?t=<?php
echo $modified?>&f=<?php echo $filename?>" media="screen">
diff --git a/include/layout.inc b/include/layout.inc
index c69d390b32..f359462dca 100644
--- a/include/layout.inc
+++ b/include/layout.inc
@@ -421,12 +421,13 @@ EOT;
return $retval;
}
-function site_header(string $title = 'Hypertext Preprocessor', array $config = []): void
+function site_header(?string $title = NULL, array $config = []): void
{
global $MYSITE, $LANG;
+ $title = $title ? "PHP: {$title}" : 'PHP';
$meta_image_path = $MYSITE . 'images/meta-image.png';
- $meta_description = "PHP is a popular general-purpose scripting language that powers
everything from your blog to the most popular websites in the world.";
+ $meta_description = $config['description'] ?? $title;
$defaults = [
"lang" => $LANG,
@@ -441,13 +442,13 @@ function site_header(string $title = 'Hypertext Preprocessor', array
$config = [
<meta name="twitter:card" content="summary_large_image" />
<meta name="twitter:site" content="@official_php" />
-<meta name="twitter:title" content="PHP: Hypertext Preprocessor" />
+<meta name="twitter:title" content="{$title}" />
<meta name="twitter:description" content="{$meta_description}" />
<meta name="twitter:creator" content="@official_php" />
<meta name="twitter:image:src" content="{$meta_image_path}" />
-<meta itemprop="name" content="PHP: Hypertext Preprocessor" />
-<meta itemprop="description" content="$meta_description" />
+<meta itemprop="name" content="{$title}" />
+<meta itemprop="description" content="{$meta_description}" />
<meta itemprop="image" content="{$meta_image_path}" />
<meta property="og:image" content="{$meta_image_path}" />
diff --git a/include/shared-manual.inc b/include/shared-manual.inc
index eb0437e278..da121ff3ed 100644
--- a/include/shared-manual.inc
+++ b/include/shared-manual.inc
@@ -325,6 +325,7 @@ function manual_setup($setup): void {
"prev" => $setup["prev"],
"next" => $setup["next"],
"cache" => $lastmod,
+ "description" => $setup["this"][2] ?? null,
];
site_header($setup["this"][1] . " - Manual ", $config);
diff --git a/index.php b/index.php
index 5e52b8a57c..9808189f79 100644
--- a/index.php
+++ b/index.php
@@ -108,7 +108,7 @@
</div>
EOF;
-site_header("Hypertext Preprocessor",
+site_header(NULL,
[
'current' => 'home',
'headtags' => [