Skip to content

Meta Tags Reference

Rumen Damyanov edited this page Sep 22, 2025 · 1 revision

Meta Tags Reference

Comprehensive guide to all meta tags generated by the PHP-SEO package, including HTML standards, Open Graph, Twitter Cards, and other structured metadata.

Overview

The PHP-SEO package generates a complete set of meta tags for optimal SEO and social media sharing. All tags are generated based on content analysis and configuration settings.

Standard HTML Meta Tags

Basic Meta Tags

<title>Page Title - Site Name</title>
<meta name="description" content="Page description for search engines">
<meta name="keywords" content="keyword1, keyword2, keyword3">
<meta name="author" content="Author Name">
<meta name="language" content="en">
<meta name="robots" content="index, follow">

Viewport and Device Meta Tags

<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="format-detection" content="telephone=no">
<meta name="mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-capable" content="yes">

Content and Security Meta Tags

<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta http-equiv="Content-Security-Policy" content="default-src 'self'">
<meta name="referrer" content="strict-origin-when-cross-origin">

Open Graph Meta Tags

Open Graph tags enable rich sharing on social platforms like Facebook, LinkedIn, and others.

Basic Open Graph Tags

<meta property="og:type" content="website">
<meta property="og:title" content="Page Title">
<meta property="og:description" content="Page description">
<meta property="og:url" content="https://example.com/page">
<meta property="og:image" content="https://example.com/image.jpg">
<meta property="og:site_name" content="Site Name">
<meta property="og:locale" content="en_US">

Article-Specific Open Graph Tags

<meta property="og:type" content="article">
<meta property="article:author" content="Author Name">
<meta property="article:published_time" content="2024-01-01T00:00:00Z">
<meta property="article:modified_time" content="2024-01-02T00:00:00Z">
<meta property="article:section" content="Technology">
<meta property="article:tag" content="SEO">
<meta property="article:tag" content="Meta Tags">

Image Open Graph Tags

<meta property="og:image" content="https://example.com/image.jpg">
<meta property="og:image:alt" content="Image description">
<meta property="og:image:width" content="1200">
<meta property="og:image:height" content="630">
<meta property="og:image:type" content="image/jpeg">

Twitter Card Meta Tags

Twitter Cards provide rich previews when links are shared on Twitter.

Summary Card

<meta name="twitter:card" content="summary">
<meta name="twitter:site" content="@website">
<meta name="twitter:creator" content="@author">
<meta name="twitter:title" content="Page Title">
<meta name="twitter:description" content="Page description">
<meta name="twitter:image" content="https://example.com/image.jpg">
<meta name="twitter:image:alt" content="Image description">

Large Image Summary Card

<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:site" content="@website">
<meta name="twitter:title" content="Page Title">
<meta name="twitter:description" content="Page description">
<meta name="twitter:image" content="https://example.com/large-image.jpg">
<meta name="twitter:image:alt" content="Large image description">

Schema.org Structured Data

JSON-LD structured data for enhanced search results.

Article Schema

<script type="application/ld+json">
{
  "@context": "https://schema.org",
  "@type": "Article",
  "headline": "Article Title",
  "description": "Article description",
  "author": {
    "@type": "Person",
    "name": "Author Name"
  },
  "datePublished": "2024-01-01",
  "dateModified": "2024-01-02",
  "image": "https://example.com/image.jpg",
  "publisher": {
    "@type": "Organization",
    "name": "Publisher Name",
    "logo": {
      "@type": "ImageObject",
      "url": "https://example.com/logo.jpg"
    }
  }
}
</script>

Website Schema

<script type="application/ld+json">
{
  "@context": "https://schema.org",
  "@type": "WebSite",
  "name": "Website Name",
  "url": "https://example.com",
  "description": "Website description",
  "potentialAction": {
    "@type": "SearchAction",
    "target": "https://example.com/search?q={search_term_string}",
    "query-input": "required name=search_term_string"
  }
}
</script>

Robots Meta Tags

Control how search engines crawl and index your content.

Standard Robots Directives

<meta name="robots" content="index, follow">
<meta name="robots" content="noindex, nofollow">
<meta name="robots" content="index, nofollow">
<meta name="robots" content="noindex, follow">

Advanced Robots Directives

<meta name="robots" content="index, follow, noarchive">
<meta name="robots" content="index, follow, nosnippet">
<meta name="robots" content="index, follow, noimageindex">
<meta name="robots" content="index, follow, max-snippet:160">
<meta name="robots" content="index, follow, max-image-preview:large">
<meta name="robots" content="index, follow, max-video-preview:30">

Search Engine Specific

<meta name="googlebot" content="index, follow">
<meta name="bingbot" content="index, follow">
<meta name="slurp" content="index, follow">

Configuration Examples

Basic Configuration

use Rumenx\PhpSeo\Config\SeoConfig;

$config = new SeoConfig([
    'meta_tags' => [
        'robots' => [
            'index' => true,
            'follow' => true,
            'archive' => false
        ],
        'open_graph' => [
            'enabled' => true,
            'site_name' => 'My Website',
            'locale' => 'en_US'
        ],
        'twitter' => [
            'enabled' => true,
            'site' => '@mywebsite',
            'card_type' => 'summary_large_image'
        ]
    ]
]);

Advanced Configuration

$config = new SeoConfig([
    'meta_tags' => [
        'generator' => 'PHP-SEO Package',
        'copyright' => '© 2024 My Company',
        'rating' => 'general',
        'distribution' => 'global',
        'revisit_after' => '7 days',
        'robots' => [
            'index' => true,
            'follow' => true,
            'archive' => false,
            'snippet' => true,
            'imageindex' => true,
            'max_snippet' => 160,
            'max_image_preview' => 'large'
        ],
        'verification' => [
            'google' => 'google-verification-code',
            'bing' => 'bing-verification-code',
            'yandex' => 'yandex-verification-code'
        ]
    ]
]);

Generation Examples

Basic Meta Tag Generation

use Rumenx\PhpSeo\SeoManager;

$seo = new SeoManager($config);
$content = '<h1>My Page</h1><p>Page content...</p>';

$metaTags = $seo->analyze($content, [
    'title' => 'Page Title',
    'description' => 'Page description',
    'url' => 'https://example.com/page',
    'image' => 'https://example.com/image.jpg'
])->generateMetaTags();

echo $seo->renderMetaTags($metaTags);

Custom Meta Tags

$customMeta = [
    'author' => 'John Doe',
    'copyright' => '© 2024 My Company',
    'keywords' => ['seo', 'meta tags', 'optimization']
];

$metaTags = $seo->generateMetaTags($customMeta);

Conditional Meta Tags

$config = new SeoConfig([
    'meta_tags' => [
        'open_graph' => [
            'enabled' => $isArticle, // Only for articles
        ],
        'twitter' => [
            'enabled' => $hasTwitterAccount,
        ]
    ]
]);

Best Practices

Title Tags

  • Keep under 60 characters
  • Include primary keyword
  • Make it unique and descriptive
  • Include brand name when appropriate

Description Tags

  • Keep between 150-160 characters
  • Include primary and secondary keywords
  • Make it compelling and actionable
  • Unique for each page

Open Graph Images

  • Use 1200x630 pixels for best results
  • Keep file size under 8MB
  • Use high-quality, relevant images
  • Include alt text for accessibility

Twitter Cards

  • Choose appropriate card type
  • Test with Twitter Card Validator
  • Include proper attribution
  • Optimize images for mobile viewing

Robots Meta Tags

  • Be specific about crawling instructions
  • Use noindex for duplicate or thin content
  • Consider nofollow for untrusted links
  • Test impact on search visibility

Validation and Testing

Validation Tools

Testing in PHP-SEO

// Validate generated meta tags
$validator = new MetaTagValidator();
$issues = $validator->validate($metaTags);

foreach ($issues as $issue) {
    echo "Warning: {$issue->getMessage()}\n";
}

Troubleshooting

Common Issues

  1. Missing Open Graph Images

    • Ensure image URLs are absolute
    • Check image dimensions and file size
    • Verify image accessibility
  2. Invalid Twitter Cards

    • Use Twitter Card Validator
    • Check card type compatibility
    • Verify required fields
  3. Robots Tag Conflicts

    • Avoid conflicting directives
    • Check robots.txt alignment
    • Test crawl accessibility

Debug Mode

$config = new SeoConfig([
    'debug' => true,
    'meta_tags' => [
        'validation' => true
    ]
]);

// Will output validation warnings
$metaTags = $seo->generateMetaTags();

This comprehensive meta tags reference ensures your content is properly optimized for search engines and social media platforms.

Clone this wiki locally