Skip to content

Documentation

Import and export blog content

Use these commands to move Off the Shelf articles between the database and the version-controlled JSON files in content/off-the-shelf/.

Validate an import without changing the database first:

Terminal window
php artisan blog:import --dry-run

Import articles that do not already exist:

Terminal window
php artisan blog:import

Overwrite database articles with matching slugs:

Terminal window
php artisan blog:import --force

Use a different content directory:

Terminal window
php artisan blog:import --path=/absolute/path/to/content --dry-run

The command reports how many articles it created, updated, and skipped. Without --force, an existing article with the same slug is skipped.

Export the database’s current articles to the default version-controlled directory:

Terminal window
php artisan blog:export

Or export to another directory:

Terminal window
php artisan blog:export --path=/absolute/path/to/content

Review the resulting JSON changes with Git before committing them.

  • app/Console/Commands/ImportBlogContent.php
  • app/Console/Commands/ExportBlogContent.php
  • app/Support/BlogContentRepository.php
  • content/off-the-shelf/