All checks were successful
Deploy / Deploy to Production (push) Successful in 7s
Add default descriptions for social sharing cards: - FR: "Boutique de Index, ONG d'investigation indépendante" - EN: "Index shop, independent investigative NGO" Changes: - Add language-specific default descriptions - Fix description excerpt handling - Add OG image generation helper (create-og-image.html) - Use favicon as temporary OG image (TODO: create proper 1200x630 image) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
79 lines
3 KiB
PHP
79 lines
3 KiB
PHP
<?php
|
|
/**
|
|
* SEO meta tags
|
|
*/
|
|
|
|
// Language
|
|
$lang = $kirby->language()->code();
|
|
|
|
// Basic meta
|
|
$title = $page->customTitle()->or($page->title())->value();
|
|
$siteName = 'Index.ngo';
|
|
$fullTitle = $title . ' | ' . $siteName;
|
|
|
|
// Default descriptions by language
|
|
$defaultDescriptionFr = 'Boutique de Index, ONG d\'investigation indépendante';
|
|
$defaultDescriptionEn = 'Index shop, independent investigative NGO';
|
|
$defaultDescription = $lang == 'en' ? $defaultDescriptionEn : $defaultDescriptionFr;
|
|
|
|
$description = $page->metaDescription()->or($page->description())->value();
|
|
if ($description) {
|
|
$description = excerpt($description, 160);
|
|
} else {
|
|
$description = $defaultDescription;
|
|
}
|
|
|
|
$url = $page->url();
|
|
// Use product image if available, otherwise use default OG image
|
|
// TODO: Create assets/og-logo.png (1200x630px) with Index logo + description
|
|
$image = $page->image() ? $page->image()->url() : url('assets/favicon.png');
|
|
?>
|
|
|
|
<!-- Basic Meta Tags -->
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title><?= $fullTitle ?></title>
|
|
<?php if ($description): ?>
|
|
<meta name="description" content="<?= $description ?>">
|
|
<?php endif ?>
|
|
|
|
<!-- Canonical & Alternate Languages -->
|
|
<link rel="canonical" href="<?= $url ?>">
|
|
<?php foreach($kirby->languages() as $language): ?>
|
|
<link rel="alternate" hreflang="<?= $language->code() ?>" href="<?= $page->url($language->code()) ?>">
|
|
<?php endforeach ?>
|
|
<link rel="alternate" hreflang="x-default" href="<?= $page->url('fr') ?>">
|
|
|
|
<!-- Open Graph -->
|
|
<meta property="og:type" content="<?= $page->template() == 'product' ? 'product' : 'website' ?>">
|
|
<meta property="og:site_name" content="<?= $siteName ?>">
|
|
<meta property="og:title" content="<?= $title ?>" id="og-title">
|
|
<meta property="og:description" content="<?= $description ?>" id="og-description">
|
|
<meta property="og:url" content="<?= $url ?>">
|
|
<meta property="og:image" content="<?= $image ?>" id="og-image">
|
|
<meta property="og:image:width" content="1200">
|
|
<meta property="og:image:height" content="630">
|
|
<meta property="og:locale" content="<?= $lang == 'fr' ? 'fr_FR' : 'en_US' ?>">
|
|
<?php foreach($kirby->languages() as $language): ?>
|
|
<?php if ($language->code() != $lang): ?>
|
|
<meta property="og:locale:alternate" content="<?= $language->code() == 'fr' ? 'fr_FR' : 'en_US' ?>">
|
|
<?php endif ?>
|
|
<?php endforeach ?>
|
|
<?php if ($page->template() == 'product'): ?>
|
|
<!-- Product-specific OG tags (will be updated by JS) -->
|
|
<meta property="product:price:amount" content="0" id="og-price">
|
|
<meta property="product:price:currency" content="EUR">
|
|
<meta property="product:availability" content="in stock" id="og-availability">
|
|
<meta property="product:brand" content="Index.ngo">
|
|
<?php endif ?>
|
|
|
|
<!-- Twitter Card -->
|
|
<meta name="twitter:card" content="summary_large_image">
|
|
<meta name="twitter:title" content="<?= $title ?>">
|
|
<?php if ($description): ?>
|
|
<meta name="twitter:description" content="<?= $description ?>">
|
|
<?php endif ?>
|
|
<meta name="twitter:image" content="<?= $image ?>">
|
|
|
|
<!-- Favicon -->
|
|
<link rel="icon" type="image/png" href="<?= url('assets/favicon.png') ?>">
|