Add management command to export a site to Hugo#118
Draft
Conversation
…unctions Agent-Logs-Url: https://github.com/veselosky/django-commoncontent/sessions/a3d97e1a-82a6-4ea4-a609-4cbd7185bb60 Co-authored-by: veselosky <103601+veselosky@users.noreply.github.com>
…comment Agent-Logs-Url: https://github.com/veselosky/django-commoncontent/sessions/a3d97e1a-82a6-4ea4-a609-4cbd7185bb60 Co-authored-by: veselosky <103601+veselosky@users.noreply.github.com>
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
- Remove the .html from bundle dir names - Do not use "" as default path. Security hole. - Get current home page the right way
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.pyexport_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>referencesexport_site(site, outdir, mode, force)— breadth-first export: HomePage → Page → Section → Article, plusstatic/$domain/→assets/.yamlmetadata files (title, mime_type, upload_date, tags; images add alt_text, width, height)force=True), remove (nuke and rebuild)src/commoncontent/management/commands/export_hugo.pyexport_hugo <site> <outdir> [--skip|--overwrite|--remove] [--force]--removerequires interactive confirmationFront matter mapping
HomePage/Section →
_index.html; Page/Article →index.html. Bundle path derived fromget_absolute_url().Tests
26 test cases in
tests/test_export_hugo.pyusing 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=...).