Transform Pushword in a FlatFile CMS.
composer require pushword/flat-file
Globally under pushword_static_generator (in config/packages).
Or for multi-sites in config/package/pushword.yaml.
...:
flat_content_dir: content #default value
# Sync : automatically detects whether to import (files newer than DB) or export (DB newer or no files).
php bin/console pw:flat:sync [host]
# imports flat files into the database
php bin/console pw:flat:import [host]
# exports database content to flat files
php bin/console pw:flat:export [host] [exportDir] [--force]
Where:
host is facultative (uses default app if not provided)exportDir (for export only) is facultative (uses flat_content_dir by default)--force (for export only) forces overwriting even if files are newer than DBphp bin/console pw:ai-index [host] [exportDir]
Generate two CSV files (pages.csv and medias.csv) with metadata useful for AI tools.
Where:
host is facultative (uses default app if not provided)exportDir is facultative (uses flat_content_dir by default)pages.csvContains page metadata with the following columns:
slug - Page slugh1 - Page H1 titlecreatedAt - Creation date (Y-m-d H:i:s)tags - Page tagssummary - Page summary/excerptmediaUsed - Comma-separated list of media files used in the pageparentPage - Parent page slug (if any)pageLinked - Comma-separated list of page slugs linked in the contentlength - Content length in charactersmedias.csvContains media metadata with the following columns:
media - Media filenamemimeType - MIME typename - Media nameusedInPages - Comma-separated list of page slugs using this mediaBy default, the content may be organized in content/%main_host%/ dir and image may be in content/%main_host%/media or in media
Eg:
content
content/homepage.md
content/kitchen-skink.md
content/other-example-kitchen-sink.md
content/en/homepage.md
content/en/kitchen-skink.md
content/media/default/illustation.jpg
content/media/default/illustation.jpg.yaml
kitchen-sink.md may contain :
---
h1: 'Welcome in Kitchen Sink'
locale: fr
translations:
- en/kitchen-skink
main_image: illustration.jpg
images:
- illustration.jpg
parent:
- homepage
metaRobots: 'no-index'
name: 'Kitchen Sink'
title: 'Kitchen Sink - best google restult'
#created_at: 'now' # see https://www.php.net/manual/fr/datetime.construct.php
#updated_at: 'now'
---
My Page content Yeah !
Good to know :
.md) and can be override by a property in yaml fronthomepage 's file could be named index.md or homepage.mdcustomPropertiesThe translations property handles the bidirectional many-to-many relationship between pages for internationalization (hreflang).
Key behaviors:
translations property, existing translations in the database are preserved unchanged.translations: [] to explicitly remove all translations from a page.Examples:
# In fr/about.md - adds en/about as translation
---
translations:
- en/about
---
# In en/about.md - no translations key, existing links preserved
---
h1: About Us
---
With this setup, both pages will be linked as translations of each other after sync.
To remove a translation, you must explicitly set an empty array in both files, or remove the translation from one file while the other file doesn't have a translations key (letting the removal propagate).
When uploading media through the admin interface, Pushword automatically:
For images:
For PDFs:
When importing media via flat files, server-side optimizations are skipped. The optimization commands work on Media entities in the database, so you must import first:
# 1. First, import flat files to database (registers media)
php bin/console pw:flat:import
# 2. Then generate image cache (responsive variants + WebP)
php bin/console pw:image:cache
# 3. Optimize images (lossless compression with optipng, jpegoptim, etc.)
php bin/console pw:image:optimize
# 4. Optimize PDFs (requires ghostscript and/or qpdf)
php bin/console pw:pdf:optimize
One-liner:
php bin/console pw:flat:import && php bin/console pw:image:cache && php bin/console pw:pdf:optimize
Browser-side scaling (1980x1280) only happens via admin upload. For flat file imports, resize images beforehand using ImageMagick:
# Resize all images in media/ to max 1980x1280 (preserves aspect ratio, only shrinks)
find content/media/ -type f \( -iname "*.jpg" -o -iname "*.jpeg" -o -iname "*.png" -o -iname "*.webp" \) \
-exec mogrify -resize '1980x1280>' {} \;
Tip: The
>flag means "only shrink larger images, never enlarge smaller ones".