====== WvdS.DokuWiki.OpenGraph Plugin ====== **Plugin:** wvdsopengraph\\ **Version:** 1.0.0\\ **Namespace:** ''lib/plugins/wvdsopengraph/''\\ **Author:** Wolfgang van der Stille \\ **License:** GPL 2 ---- ===== Definition ===== The **wvdsopengraph** plugin generates Open Graph and Twitter Card meta tags for optimal display when sharing on social media. It supports multilingual content and page-specific overrides. ===== Use Cases ===== * **Social Media Sharing** - Optimized preview on Facebook, LinkedIn, Twitter * **SEO Improvement** - Structured meta data for search engines * **Multilingual Wikis** - Automatic language detection for meta tags * **Branding** - Consistent appearance when linking ---- ===== Syntax ===== title = Page Title description = Description image = :wiki:logo.png type = article ==== Parameters ==== ^ Parameter ^ Type ^ Default ^ Description ^ | ''title'' | string | //(page title)// | Title for social media | | ''description'' | string | //(tagline)// | Description (max. 160 characters) | | ''image'' | string | //(default image)// | DokuWiki media path | | ''type'' | string | article | Open Graph type | ---- ===== Multilingual Values ===== All values support the pipe format: title = de:Kryptographie|en:Cryptography|sl:Kriptografija description = de:Einführung|en:Introduction|sl:Uvod The plugin automatically detects the language from the namespace path. ---- ===== Automatic Tags ===== Without an '''' block, the plugin automatically generates: ^ Tag ^ Source ^ | ''og:title'' | Page title (H1) | | ''og:description'' | Wiki tagline or defaultDescription | | ''og:url'' | Current page URL | | ''og:site_name'' | Wiki title | | ''og:type'' | article | | ''og:image'' | defaultImage from configuration | ---- ===== Examples ===== ==== Example 1: Simple Override ==== title = My Project description = A comprehensive project description image = :projects:banner.jpg ====== My Project ====== Page content... ==== Example 2: Multilingual ==== title = de:OpenSSL Dokumentation|en:OpenSSL Documentation description = de:Umfassende Anleitung|en:Comprehensive guide image = :crypto:openssl-banner.png ---- ===== Generated HTML Tags ===== ---- ===== Configuration ===== ==== Admin Settings ==== Via **Admin → Configuration → wvdsopengraph**: ^ Setting ^ Type ^ Default ^ Description ^ | ''defaultDescription'' | Text | //(tagline)// | Default description (multilingual) | | ''defaultImage'' | Text | //(empty)// | Default image media ID | | ''twitterSite'' | Text | //(empty)// | Twitter @username for twitter:site | | ''enableTwitterCards'' | On/Off | On | Generate Twitter Card tags | ---- ===== How It Works ===== ==== Processing Pipeline ==== 1. Page Parsing └── Searches for ... block at page start 2. Parameter Extraction └── Parses key = value pairs └── Detects de:X|en:Y format 3. Language Detection └── Determines language from namespace └── Extracts matching value 4. Meta Tag Generation └── Creates og:* and twitter:* tags └── Inserts into ---- ===== Error Handling ===== ^ Scenario ^ Behavior ^ | No block | Uses automatic values | | Image not found | Uses defaultImage | | Invalid language | Fallback to first value | | Empty value | Tag is not generated | ---- ===== Best Practices ===== * **Description:** Maximum 160 characters * **Title:** Maximum 60 characters * **Image:** Minimum 1200×630 pixels for optimal display * **Format:** JPEG or PNG for images ---- ===== Version History ===== ^ Version ^ Date ^ Changes ^ | 1.0.0 | 2025-01-06 | Initial release | ---- ===== See Also ===== * [[wvdslang]] - Multilingual translations * [[wvdsimage]] - Image optimization * [[https://ogp.me/|Open Graph Protocol]] * [[https://developer.twitter.com/en/docs/twitter-for-websites/cards|Twitter Cards]] ---- ===== Technical Reference ===== ==== Class: syntax_plugin_wvdsopengraph ==== **File:** ''lib/plugins/wvdsopengraph/syntax.php'' ^ Method ^ Description ^ | ''getType()'' | Returns ''substition'' | | ''getSort()'' | Returns ''50'' (early) | | ''handle($match, ...)'' | Parses block | | ''render($mode, ...)'' | No output (meta tags only) | ==== Class: action_plugin_wvdsopengraph ==== **File:** ''lib/plugins/wvdsopengraph/action.php'' ^ Method ^ Description ^ | ''register()'' | Registers TPL_METAHEADER_OUTPUT event | | ''addMetaTags()'' | Inserts meta tags into header | ---- {{wvds:snippet>wvds_audit_badge}} ~~DISCUSSION~~