Skip to content

Add management command to export a site to Hugo#118

Draft
Copilot wants to merge 8 commits intomainfrom
copilot/create-management-command-export-hugo
Draft

Add management command to export a site to Hugo#118
Copilot wants to merge 8 commits intomainfrom
copilot/create-management-command-export-hugo

Conversation

Copy link
Copy Markdown

Copilot AI commented Apr 9, 2026

Export Common Content sites to Hugo-compatible directory structures with YAML front matter, page bundles, media resources, and static assets. Supports incremental export with skip/overwrite/remove modes.

src/commoncontent/actions.py

  • export_page(instance, content_dir, mode, force) — exports any BasePage subclass as a Hugo page bundle with YAML front matter, body HTML, rich description, share image, image collections, attachments, and inline <img> references
  • export_site(site, outdir, mode, force) — breadth-first export: HomePage → Page → Section → Article, plus static/$domain/assets/
  • Media files get companion .yaml metadata files (title, mime_type, upload_date, tags; images add alt_text, width, height)
  • Three modes: skip (default, no overwrites), overwrite (mtime-aware unless force=True), remove (nuke and rebuild)

src/commoncontent/management/commands/export_hugo.py

  • export_hugo <site> <outdir> [--skip|--overwrite|--remove] [--force]
  • Site resolved by ID or domain; --remove requires interactive confirmation

Front matter mapping

title: instance.title
subtitle: instance.subtitle
seo_title: instance.seo_title
description: instance.seo_description
draft: true  # unless status == USABLE
publishdate: instance.date_published
lastmod: instance.date_modified
dateCreated: instance.date_created
expirydate: instance.expires
copyright: instance.copyright_notice
icon_name: instance.icon_name
cover: instance.share_image.url

HomePage/Section → _index.html; Page/Article → index.html. Bundle path derived from get_absolute_url().

Tests

26 test cases in tests/test_export_hugo.py using real DB fixtures and tiny test files (10×10 JPEG, text attachment, domain static CSS). Covers all page types, front matter fields, media/attachment metadata, skip/overwrite semantics, series URL paths, and static file export via @override_settings(STATIC_ROOT=...).

Copilot AI linked an issue Apr 9, 2026 that may be closed by this pull request
Copilot AI changed the title [WIP] Add command to export site to Hugo format Add management command to export a site to Hugo Apr 9, 2026
Copilot AI requested a review from veselosky April 9, 2026 14:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Command to export a site to Hugo

2 participants