PHPackages                             sordahl/webflow-parser - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Parsing &amp; Serialization](/categories/parsing)
4. /
5. sordahl/webflow-parser

ActiveLibrary[Parsing &amp; Serialization](/categories/parsing)

sordahl/webflow-parser
======================

Webflow site parser to static html with local assets and translations

1.1.10(4mo ago)019MITPHPPHP ^8.3

Since Feb 19Pushed 4mo agoCompare

[ Source](https://github.com/sordahl/webflow-parser)[ Packagist](https://packagist.org/packages/sordahl/webflow-parser)[ RSS](/packages/sordahl-webflow-parser/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)DependenciesVersions (12)Used By (0)

Webflow Website Generator
=========================

[](#webflow-website-generator)

A comprehensive PHP-based static site generator for Webflow sites with multi-language support, automatic sitemap generation, and SEO optimization.

Features
--------

[](#features)

- 🌍 **Multi-language support** - Automatically generates locale-specific pages
- 🗺️ **Auto-detecting sitemap** - Automatically detects supported languages and creates SEO-optimized sitemap.xml
- 🤖 **Robots.txt generation** - Automatically generated with sitemap reference
- 🏷️ **Open Graph tags** - Includes og:site\_name and other meta tags for social sharing
- 🔄 **Translation system** - Compares JSON DOM structures to generate accurate translations
- 📦 **Asset management** - Downloads and manages external assets locally
- 🔗 **SEO optimized** - Proper hreflang tags, alternate links, and meta translations
- ⚡ **Unified generator** - Single command to generate complete site
- 🗜️ **Minification** - Compresses inline CSS and JavaScript for faster page loads

Quick Start
-----------

[](#quick-start)

### Prerequisites

[](#prerequisites)

- PHP 8.3 or higher
- Composer
- Webflow API key

### Installation

[](#installation)

1. Install dependencies:

```
composer install
```

2. Create `.env` file with your Webflow API key:

```
echo 'WEBFLOW_API="your-api-key-here"' . PHP_EOL > .env
```

### Generate Your Site

[](#generate-your-site)

Simply run the unified generator script:

```
php generate-site.php
```

This single command will:

1. ✅ Fetch and generate all locale-specific HTML pages
2. ✅ Generate sitemap.xml with auto-detected languages
3. ✅ Generate robots.txt
4. ✅ Copy public files to dist directory

Architecture
------------

[](#architecture)

### Core Classes

[](#core-classes)

- **`WebflowLocaleFetcher`** - Main orchestrator for fetching and generating locale-specific pages
- **`SitemapGenerator`** - Generates SEO-optimized sitemap.xml and robots.txt with auto-detected locales
- **`HtmlProcessor`** - Processes and transforms HTML (cleanup, assets, translations, meta tags)
- **`TranslationBuilder`** - Builds translation maps by comparing JSON DOM structures
- **`LocaleGenerator`** - Generates and saves locale-specific HTML files
- **`WebflowApiClient`** - Handles all Webflow API interactions

### Directory Structure

[](#directory-structure)

```
/
├── generate-site.php            # ⭐ Main unified generator (use this!)
├── generate-locale-pages.php   # Legacy: locale pages only
├── generate-sitemap.php         # Legacy: sitemap only
├── composer.json
├── .env
└── src/
    ├── WebflowLocaleFetcher.php  # Main orchestrator
    ├── SitemapGenerator.php       # Sitemap & robots.txt generator
    ├── HtmlProcessor.php          # HTML processing & meta tags
    ├── TranslationBuilder.php     # Translation logic
    ├── LocaleGenerator.php        # File generation
    └── WebflowApiClient.php       # API communication

dist/                           # Generated output
├── index.html                  # Primary language (English)
├── da/                        # Danish locale folder
│   └── index.html             # Translated Danish page
├── sitemap.xml                # SEO sitemap with hreflang
├── robots.txt                 # Search engine instructions
├── json/                      # JSON DOM files
│   ├── page-content-*-default.json
│   └── page-content-*-da.json
└── assets/                    # Downloaded assets
    ├── *.css
    ├── *.js
    └── *.svg

```

Configuration
-------------

[](#configuration)

Edit the `$config` array in `generate-site.php`:

```
$config = [
    'apiKey' => $apiKey,                              // From .env file
    'siteId' => '',                  // Your Webflow site ID
    'siteUrl' => 'https://example.webflow.io',        // Webflow staging URL
    'hostUrl' => 'https://example.com',               // Your production domain
    'outputDir' => __DIR__ . '/dist',                 // Output directory
    'site_name' => 'SiteName',                         // For og:site_name meta tag

    // Options
    'fetchContent' => true,      // Fetch JSON DOM structure
    'fetchHtml' => true,         // Fetch rendered HTML
    'downloadAssets' => true,    // Download external assets
    'minifyInline' => true,      // Minify inline styles and scripts

    // Pages to exclude by ID
    'excludePageIds' => [],
];
```

How It Works
------------

[](#how-it-works)

### Translation Process

[](#translation-process)

1. **Fetch JSON DOM**: Downloads JSON representation of page structure from Webflow API
2. **Compare Structures**: Compares primary locale JSON with secondary locale JSON
3. **Build Translation Map**: Creates mapping of original text to translated text
4. **Apply Translations**: Replaces original text in HTML with translations
5. **Update Meta Tags**: Translates SEO titles, descriptions, and Open Graph tags (including og:site\_name)
6. **Fix Paths**: Updates relative paths for subdirectory locations
7. **Add Hreflang**: Adds proper language alternate links

### Sitemap Generation

[](#sitemap-generation)

1. **Auto-detect Locales**: Scans pages to identify all supported languages automatically
2. **Group Pages**: Groups pages by slug to identify translations
3. **Build Entries**: Creates sitemap entries with proper hreflang alternate links
4. **Prioritize**: Sets priority based on page type (homepage = 1.0, others = 0.8)
5. **Generate XML**: Outputs valid sitemap.xml following sitemaps.org schema

Key Features Explained
----------------------

[](#key-features-explained)

### Auto-Detecting Sitemap

[](#auto-detecting-sitemap)

The `SitemapGenerator` class automatically detects all supported languages by scanning the pages fetched from Webflow. You don't need to manually configure which languages are supported - just add them in Webflow and the generator will detect and include them in the sitemap.

```
// This method auto-detects locales from pages
private function detectLocales(array $pages): array
```

### Open Graph Site Name

[](#open-graph-site-name)

The generator automatically adds `og:site_name` meta tags to all pages (both primary and translated). Configure it in `generate-site.php`:

```
'site_name' => 'SiteName',  // Appears as
```

### Hreflang Attributes

[](#hreflang-attributes)

All pages automatically get proper hreflang alternate links for SEO:

```

```

### Inline Minification

[](#inline-minification)

The generator automatically minifies inline `` and `` tags to reduce page size and improve load times:

**Before minification:**

```

	.section-features > .feature-item:nth-child(n + 3) {
		margin-top: -20vh;
	}
	.section-features {
		overflow-x: clip;
	}

```

**After minification:**

```

	.section-features > .feature-item:nth-child(n + 3) {
		margin-top: -20vh;
	}
	.section-features {
		overflow-x: clip;
	}

```

**Features:**

- Removes CSS/JS comments
- Removes unnecessary whitespace
- Removes spaces around operators and punctuation
- Preserves functionality while reducing file size
- Can be disabled by setting `'minifyInline' => false` in config

Development
-----------

[](#development)

### Adding a New Locale

[](#adding-a-new-locale)

Locales are automatically detected from Webflow! Just add a new locale in your Webflow site settings, and the generator will detect and process it automatically.

### Excluding Pages

[](#excluding-pages)

Add page IDs to the `excludePageIds` array in `generate-site.php`:

```
'excludePageIds' => [
    '671d6147172df4affd2ed334',  // Page to exclude
],
```

### Custom Meta Tags

[](#custom-meta-tags)

To add custom meta tags, modify the `HtmlProcessor::addSiteNameMeta()` method or create a similar method in `src/HtmlProcessor.php`.

Legacy Scripts
--------------

[](#legacy-scripts)

The following scripts are still available but **not recommended** for regular use:

- `generate-locale-pages.php` - Generate only locale pages (use `generate-site.php` instead)
- `generate-sitemap.php` - Generate only sitemap (use `generate-site.php` instead)

Troubleshooting
---------------

[](#troubleshooting)

### No locales detected

[](#no-locales-detected)

- Check that locales are properly configured in Webflow
- Ensure the Webflow API key has access to the site

### Missing translations

[](#missing-translations)

- Verify that content exists in both primary and secondary locales in Webflow
- Check the `dist/json/` directory for generated JSON files
- Review translation pairs count in console output

### Broken asset links

[](#broken-asset-links)

- Ensure `downloadAssets` is set to `true` in config
- Check that the `dist/assets/` directory has write permissions
- Verify external assets are accessible

### Sitemap not updating

[](#sitemap-not-updating)

- Make sure you're running `generate-site.php` (not the legacy scripts)
- Check that all locales are published in Webflow
- Verify the `hostUrl` is correct in config

Performance
-----------

[](#performance)

- **Average generation time**: 4-6 seconds (for 2 pages with 2 locales)
- **API calls**: Approximately 4-6 per page (varies by locale count)
- **Output size**: ~20KB per page (compressed HTML + assets)

Inspired By
-----------

[](#inspired-by)

This project uses concepts from [WebflowParser](https://github.com/sordahl/webflow-parser) for asset management and HTML cleanup.

License
-------

[](#license)

Proprietary - Sordahl ApS

###  Health Score

43

—

FairBetter than 90% of packages

Maintenance82

Actively maintained with recent releases

Popularity6

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity66

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~104 days

Recently: every ~13 days

Total

11

Last Release

127d ago

PHP version history (3 changes)1.0.0PHP &gt;7.0

1.1.1PHP &gt;8.0

1.1.3PHP ^8.3

### Community

Maintainers

![](https://www.gravatar.com/avatar/7ce23649c155583c70f901f82c300fe520a3ef627009f1262801639d1aaa6729?d=identicon)[sordahl](/maintainers/sordahl)

---

Top Contributors

[![sordahl](https://avatars.githubusercontent.com/u/1076562?v=4)](https://github.com/sordahl "sordahl (74 commits)")

---

Tags

composerparserwebflow

### Embed Badge

![Health badge](/badges/sordahl-webflow-parser/health.svg)

```
[![Health](https://phpackages.com/badges/sordahl-webflow-parser/health.svg)](https://phpackages.com/packages/sordahl-webflow-parser)
```

###  Alternatives

[mtdowling/jmespath.php

Declaratively specify how to extract elements from a JSON document

2.0k472.8M135](/packages/mtdowling-jmespathphp)[opis/closure

A library that can be used to serialize closures (anonymous functions) and arbitrary data.

2.6k230.0M282](/packages/opis-closure)[masterminds/html5

An HTML5 parser and serializer.

1.8k242.8M226](/packages/masterminds-html5)[sabberworm/php-css-parser

Parser for CSS Files written in PHP

1.8k191.2M63](/packages/sabberworm-php-css-parser)[michelf/php-markdown

PHP Markdown

3.5k52.4M343](/packages/michelf-php-markdown)[jms/metadata

Class/method/property metadata management in PHP

1.8k152.8M88](/packages/jms-metadata)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
