# Comparison Pages Automation Opportunities


**Last Updated:** 2025-11-20

Documentation of potential automation opportunities for schema generation, meta tag generation, image path generation, and component include verification.

## Overview

This document identifies automation opportunities to streamline comparison page creation and maintenance, reducing manual work and improving consistency.

## Current Manual Processes

### Page Creation

1. Duplicate existing page
2. Update meta tags manually
3. Update schema JSON-LD manually
4. Update image paths manually
5. Update content manually
6. Generate image variants manually
7. Test manually

### Maintenance

1. Update pricing across pages manually
2. Update schema dates manually
3. Verify includes manually
4. Check image variants manually

## Automation Opportunities

### 1. Schema Generation

#### Current State

Schema JSON-LD is manually written/updated for each page with:

- WebPage schema
- Article schema
- Table schema
- Product schemas
- BreadcrumbList schema
- FAQPage schema

#### Automation Solution

**Script:** `scripts/generate_comparison_schema.php`

**Input:**

- Competitor name
- Competitor slug
- Competitor data (pricing, rating, etc.)
- FAQ items

**Output:**

- Complete JSON-LD schema
- Validated JSON
- Ready to paste into page

**Benefits:**

- Consistent schema structure
- Reduced errors
- Faster page creation
- Easy updates

**Implementation:**

```php
<?php
function generateComparisonSchema($competitorData) {
    $schema = [
        '@context' => 'https://schema.org',
        '@graph' => [
            generateWebPageSchema($competitorData),
            generateArticleSchema($competitorData),
            generateTableSchema($competitorData),
            generateBreadcrumbSchema($competitorData),
            generateFAQSchema($competitorData),
            generateProductSchema('Ordio'),
            generateProductSchema($competitorData['name'])
        ]
    ];
    return json_encode($schema, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
}
?>
```

### 2. Meta Tag Generation

#### Current State

Meta tags are manually written for each page:

- Title tag
- Meta description
- Keywords
- Open Graph tags
- Twitter Card tags

#### Automation Solution

**Script:** `scripts/generate_comparison_meta.php`

**Input:**

- Competitor name
- Competitor category
- Target audience
- Focus/use case

**Output:**

- Complete meta tag block
- Validated lengths
- SEO-optimized

**Benefits:**

- Consistent format
- Proper lengths
- SEO optimized
- Faster creation

**Implementation:**

```php
<?php
function generateMetaTags($competitor, $category, $audience, $focus) {
    $title = "{$competitor} Alternativen: Vergleich & Bewertung 2025 - Ordio";
    $description = "{$competitor} Alternativen im Vergleich 2025: Ordio vs {$competitor}. {$focus} für {$audience}. Finde die beste {$category}-Alternative.";

    return [
        'title' => $title,
        'description' => truncate($description, 160),
        'keywords' => generateKeywords($competitor, $category),
        'og' => generateOGTags($title, $description),
        'twitter' => generateTwitterTags($title, $description)
    ];
}
?>
```

### 3. Image Path Generation

#### Current State

Image paths are manually written:

- Hero logo paths
- Comparison column logo paths
- Carousel logo paths
- Preload links

#### Automation Solution

**Function:** `generateImagePaths($competitorSlug)`

**Input:**

- Competitor slug

**Output:**

- All image paths with srcset
- Preload link
- Ready-to-use HTML

**Benefits:**

- Consistent paths
- No typos
- Faster creation
- Easy updates

**Implementation:**

```php
<?php
function generateImagePaths($competitorSlug) {
    return [
        'hero' => [
            'src' => "/v2/img/alternativen/{$competitorSlug}-vergleich-logo-160w.webp",
            'srcset' => "/v2/img/alternativen/{$competitorSlug}-vergleich-logo-160w.webp 160w, /v2/img/alternativen/{$competitorSlug}-vergleich-logo-320w.webp 320w",
            'sizes' => "(max-width: 640px) 160px, 160px",
            'preload' => "/v2/img/alternativen/{$competitorSlug}-vergleich-logo-160w.webp"
        ],
        'carousel' => [
            'src' => "/v2/img/alternativen/{$competitorSlug}-logo-64w.webp",
            'srcset' => "/v2/img/alternativen/{$competitorSlug}-logo-64w.webp 64w, /v2/img/alternativen/{$competitorSlug}-logo-128w.webp 128w",
            'sizes' => "(max-width: 640px) 64px, 64px"
        ]
    ];
}
?>
```

### 4. Component Include Verification

#### Current State

Includes are manually checked:

- Verify all includes present
- Check include paths
- Verify variables set

#### Automation Solution

**Script:** `scripts/verify_comparison_includes.php`

**Input:**

- Page file path

**Output:**

- List of missing includes
- Incorrect paths
- Missing variables
- Validation report

**Benefits:**

- Catch errors early
- Ensure consistency
- Faster validation

**Implementation:**

```php
<?php
function verifyIncludes($pageFile) {
    $requiredIncludes = [
        '../base/head.php',
        '../base/header.php',
        '../components/ordio_comparison_content.php',
        '../base/compare_carousel.php',
        '../base/footer.php',
        '../components/lead-capture-popup.php'
    ];

    $content = file_get_contents($pageFile);
    $missing = [];

    foreach ($requiredIncludes as $include) {
        if (strpos($content, $include) === false) {
            $missing[] = $include;
        }
    }

    return [
        'missing' => $missing,
        'all_present' => empty($missing)
    ];
}
?>
```

### 5. Image Variant Verification

#### Current State

Image variants are manually checked:

- Verify all variants exist
- Check file names
- Verify dimensions

#### Automation Solution

**Script:** `scripts/verify_image_variants.php`

**Input:**

- Competitor slug

**Output:**

- List of missing variants
- File size information
- Validation report

**Benefits:**

- Catch missing images early
- Verify optimization
- Ensure consistency

**Implementation:**

```php
<?php
function verifyImageVariants($competitorSlug) {
    $requiredVariants = [
        "{$competitorSlug}-logo-64w.webp",
        "{$competitorSlug}-logo-80w.webp",
        "{$competitorSlug}-logo-128w.webp",
        "{$competitorSlug}-logo-160w.webp",
        "{$competitorSlug}-vergleich-logo-160w.webp",
        "{$competitorSlug}-vergleich-logo-320w.webp"
    ];

    $basePath = __DIR__ . '/../v2/img/alternativen/';
    $missing = [];
    $sizes = [];

    foreach ($requiredVariants as $variant) {
        $path = $basePath . $variant;
        if (!file_exists($path)) {
            $missing[] = $variant;
        } else {
            $sizes[$variant] = filesize($path);
        }
    }

    return [
        'missing' => $missing,
        'sizes' => $sizes,
        'all_present' => empty($missing)
    ];
}
?>
```

### 6. Page Template Generation

#### Current State

Pages are created by duplicating existing page and manually updating.

#### Automation Solution

**Script:** `scripts/generate_comparison_page.php`

**Input:**

- Competitor name
- Competitor slug
- Competitor data
- Template file

**Output:**

- Complete comparison page file
- All placeholders replaced
- Ready for content review

**Benefits:**

- Faster page creation
- Consistent structure
- Fewer errors
- Standardized format

**Implementation:**

```php
<?php
function generateComparisonPage($competitorData, $templateFile = 'compare_template.php') {
    $template = file_get_contents($templateFile);

    $replacements = [
        '{COMPETITOR}' => $competitorData['name'],
        '{competitor}' => $competitorData['slug'],
        '{competitor-slug}' => str_replace('_', '-', $competitorData['slug']),
        '{META_TITLE}' => generateMetaTitle($competitorData),
        '{META_DESCRIPTION}' => generateMetaDescription($competitorData),
        '{SCHEMA_JSON}' => generateComparisonSchema($competitorData),
        '{IMAGE_PATHS}' => generateImagePaths($competitorData['slug'])
    ];

    $content = str_replace(array_keys($replacements), array_values($replacements), $template);

    return $content;
}
?>
```

### 7. Bulk Updates

#### Current State

Updates across multiple pages done manually:

- Pricing updates
- Schema date updates
- Content updates

#### Automation Solution

**Script:** `scripts/bulk_update_comparison_pages.php`

**Input:**

- Update type (pricing, dates, content)
- New values
- Page filter (optional)

**Output:**

- Updated pages
- Change log
- Backup files

**Benefits:**

- Faster updates
- Consistent changes
- Reduced errors
- Change tracking

**Implementation:**

```php
<?php
function bulkUpdatePricing($newPrice, $pages = null) {
    $pages = $pages ?: glob(__DIR__ . '/../v2/pages/compare_*.php');
    $updated = [];

    foreach ($pages as $page) {
        $content = file_get_contents($page);
        $backup = $page . '.backup';
        copy($page, $backup);

        // Update pricing in schema
        $content = preg_replace('/"price":\s*"89"/', "\"price\": \"{$newPrice}\"", $content);

        file_put_contents($page, $content);
        $updated[] = basename($page);
    }

    return [
        'updated' => $updated,
        'count' => count($updated)
    ];
}
?>
```

### 8. Validation Automation

#### Current State

Validation done manually:

- Schema validation
- Link checking
- Image verification
- Performance testing

#### Automation Solution

**Script:** `scripts/validate_comparison_page.php`

**Input:**

- Page file path

**Output:**

- Validation report
- Issues found
- Recommendations

**Benefits:**

- Comprehensive validation
- Consistent checks
- Faster validation
- Detailed reports

**Implementation:**

```php
<?php
function validateComparisonPage($pageFile) {
    $report = [
        'schema' => validateSchema($pageFile),
        'images' => validateImages($pageFile),
        'includes' => verifyIncludes($pageFile),
        'meta_tags' => validateMetaTags($pageFile),
        'links' => validateLinks($pageFile),
        'performance' => validatePerformance($pageFile)
    ];

    return $report;
}
?>
```

## Implementation Priority

### High Priority (Immediate Value)

1. **Schema Generation** - Saves significant time, reduces errors
2. **Meta Tag Generation** - Quick wins, ensures consistency
3. **Image Path Generation** - Prevents typos, faster creation

### Medium Priority (High Value)

4. **Component Include Verification** - Catches errors early
5. **Image Variant Verification** - Prevents missing assets
6. **Page Template Generation** - Streamlines creation

### Lower Priority (Nice to Have)

7. **Bulk Updates** - Useful but less frequent
8. **Validation Automation** - Complements manual testing

## Implementation Approach

### Phase 1: Core Automation

1. Create schema generation function
2. Create meta tag generation function
3. Create image path generation function
4. Test with one page
5. Refine based on feedback

### Phase 2: Verification Tools

1. Create include verification script
2. Create image variant verification script
3. Integrate into workflow
4. Document usage

### Phase 3: Template System

1. Create page template
2. Create generation script
3. Test generation process
4. Update documentation

### Phase 4: Advanced Automation

1. Bulk update scripts
2. Validation automation
3. CI/CD integration (if applicable)

## Usage Examples

### Generate Schema

```bash
php scripts/generate_comparison_schema.php \
    --competitor="awork" \
    --name="awork" \
    --price="6.00" \
    --rating="4.6" \
    --reviews="880" \
    --output="schema.json"
```

### Generate Meta Tags

```bash
php scripts/generate_comparison_meta.php \
    --competitor="awork" \
    --category="Projektmanagement" \
    --audience="Agenturen" \
    --focus="Projektmanagement Software" \
    --output="meta_tags.php"
```

### Verify Includes

```bash
php scripts/verify_comparison_includes.php \
    --page="v2/pages/compare_awork.php"
```

### Verify Image Variants

```bash
php scripts/verify_image_variants.php \
    --competitor="awork"
```

### Generate Complete Page

```bash
php scripts/generate_comparison_page.php \
    --competitor="awork" \
    --data="competitor_data.json" \
    --output="v2/pages/compare_awork.php"
```

## Benefits Summary

### Time Savings

- **Schema Generation:** 15-20 minutes → 2 minutes
- **Meta Tag Generation:** 10 minutes → 1 minute
- **Image Path Generation:** 5 minutes → 30 seconds
- **Total per page:** 30-35 minutes → 3-4 minutes

### Error Reduction

- Consistent schema structure
- No typos in paths
- Proper meta tag lengths
- Complete includes

### Quality Improvement

- Standardized format
- Consistent structure
- Better validation
- Easier maintenance

## Future Enhancements

### AI Integration

- Generate competitor descriptions
- Generate FAQ items
- Optimize content

### CI/CD Integration

- Automated testing on commit
- Performance monitoring
- Schema validation

### Dashboard

- Page status overview
- Validation reports
- Update tracking

## Considerations

### When to Automate

- **High frequency:** Tasks done often
- **Error-prone:** Manual process has errors
- **Time-consuming:** Takes significant time
- **Repetitive:** Same steps each time

### When Not to Automate

- **One-time tasks:** Not worth automation
- **Complex logic:** Hard to automate
- **Requires judgment:** Needs human review
- **Low frequency:** Rarely done

### Maintenance

- Keep automation scripts updated
- Document usage
- Test regularly
- Version control scripts
