# content_migrator URL: /api/debug/content_migrator/ Section: debug -------------------------------------------------------------------------------- content_migrator - Bengal window.BENGAL_THEME_DEFAULTS = { appearance: 'dark', palette: 'snow-lynx' }; // Progressive Enhancement System Configuration window.Bengal = window.Bengal || {}; window.Bengal.enhanceBaseUrl = '/bengal/assets/js/enhancements'; window.Bengal.watchDom = true; window.Bengal.debug = false; (function () { try { var defaults = window.BENGAL_THEME_DEFAULTS || { appearance: 'system', palette: '' }; var defaultAppearance = defaults.appearance; if (defaultAppearance === 'system') { defaultAppearance = (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) ? 'dark' : 'light'; } var storedTheme = localStorage.getItem('bengal-theme'); var storedPalette = localStorage.getItem('bengal-palette'); var theme = storedTheme ? (storedTheme === 'system' ? defaultAppearance : storedTheme) : defaultAppearance; var palette = storedPalette ?? defaults.palette; document.documentElement.setAttribute('data-theme', theme); if (palette) { document.documentElement.setAttribute('data-palette', palette); } } catch (e) { document.documentElement.setAttribute('data-theme', 'light'); } })(); Skip to main content Magnifying Glass ESC Recent Clear Magnifying Glass No results for "" Try different keywords or check your spelling Start typing to search... ↑↓ Navigate ↵ Open ESC Close Powered by Lunr ᓚᘏᗢ Documentation Info About Arrow Clockwise Get Started Note Tutorials File Text Content Palette Theming Settings Building Starburst Extending Bookmark Reference Learning Tracks Releases Dev GitHub API Reference bengal CLI Magnifying Glass Search ⌘K Palette Appearance Chevron Down Mode Monitor System Sun Light Moon Dark Palette Snow Lynx Brown Bengal Silver Bengal Charcoal Bengal Blue Bengal List ᓚᘏᗢ Magnifying Glass Search X Close Documentation Info About Arrow Clockwise Get Started Note Tutorials File Text Content Palette Theming Settings Building Starburst Extending Bookmark Reference Learning Tracks Releases Dev GitHub API Reference bengal CLI Palette Appearance Chevron Down Mode Monitor System Sun Light Moon Dark Palette Snow Lynx Brown Bengal Silver Bengal Charcoal Bengal Blue Bengal API Reference __main__ bengal Caret Right Folder Analysis community_detection graph_analysis graph_reporting graph_visualizer knowledge_graph link_suggestions link_types page_rank path_analysis performance_advisor results Caret Right Folder Assets manifest pipeline Caret Right Folder Autodoc base config docstring_parser utils virtual_orchestrator Caret Right Folder Extractors cli openapi python Caret Right Folder Models cli common openapi python Caret Right Folder Cache asset_dependency_map cache_store cacheable compression dependency_tracker page_discovery_cache query_index query_index_registry taxonomy_index utils Caret Right Folder Build Cache autodoc_tracking core file_tracking fingerprint parsed_content_cache rendered_output_cache taxonomy_index_mixin validation_cache Caret Right Folder Indexes author_index category_index date_range_index section_index Caret Right Folder Cli __main__ base site_templates utils Caret Right Folder Commands assets build clean collections config debug explain fix health init perf project serve site skeleton sources theme utils validate Caret Right Folder Graph __main__ bridges communities orphans pagerank report suggest Caret Right Folder New config presets scaffolds site wizard Caret Right Folder Helpers cli_app_loader cli_output config_validation error_handling menu_config metadata progress site_loader traceback validation Caret Right Folder Skeleton hydrator schema Caret Right Folder Templates base registry Caret Right Folder Blog template Caret Right Folder Changelog template Caret Right Folder Default template Caret Right Folder Docs template Caret Right Folder Landing template Caret Right Folder Portfolio template Caret Right Folder Resume template Caret Right Folder Collections errors loader schemas validator Caret Right Folder Config defaults deprecation directory_loader env_overrides environment feature_mappings hash loader merge origin_tracker validators Caret Right Folder Content Layer entry loaders manager source Caret Right Folder Sources github local notion rest Caret Right Folder Content Types base registry strategies Caret Right Folder Core build_context cascade_engine menu section theme Caret Right Folder Asset asset_core css_transforms Caret Right Folder Page computed content metadata navigation operations page_core proxy relationships utils Caret Right Folder Site core data discovery factories page_caches properties section_registry theme Caret Right Folder Debug base config_inspector content_migrator delta_analyzer dependency_visualizer explainer incremental_debugger models reporter shortcode_sandbox Caret Right Folder Discovery asset_discovery content_discovery Caret Right Folder Fonts downloader generator Caret Right Folder Health autofix base health_check report Caret Right Folder Linkcheck async_checker ignore_policy internal_checker models orchestrator Caret Right Folder Validators anchors assets cache config connectivity cross_ref fonts links menu navigation output performance rendering rss sitemap taxonomy tracks Caret Right Folder Directives analysis checkers constants Caret Right Folder Orchestration asset content full_to_incremental incremental menu postprocess related_posts render section static streaming taxonomy Caret Right Folder Postprocess html_output redirects rss sitemap special_pages Caret Right Folder Output Formats index_generator json_generator llm_generator lunr_index_generator txt_generator utils Caret Right Folder Rendering api_doc_enhancer asset_extractor errors jinja_utils link_transformer link_validator pygments_cache renderer template_context template_profiler validator Caret Right Folder Parsers base factory mistune native_html pygments_patch python_markdown Caret Right Folder Pipeline core output thread_local toc transforms Caret Right Folder Plugins badges cross_references inline_icon term variable_substitution Caret Right Folder Directives _icons admonitions badge base button cache cards checklist code_tabs container contracts data_table dropdown embed errors example_label fenced figure glossary icon include list_table literalinclude marimo navigation options rubric steps tabs target term terminal tokens utils validator video Caret Right Folder Template Engine asset_url core environment manifest menu url_helpers Caret Right Folder Template Functions advanced_collections advanced_strings autodoc collections content crossref data dates debug files get_page i18n icons images math_functions navigation pagination_helpers seo strings tables taxonomies theme urls Caret Right Folder Server build_handler component_preview constants dev_server live_reload pid_manager reload_controller request_handler request_logger resource_manager utils Caret Right Folder Services validation Caret Right Folder Themes config Caret Right Folder Utils atomic_write autodoc build_context build_stats build_summary cli_output css_minifier dates dotdict error_handlers file_io file_lock hashing incremental_constants js_bundler live_progress logger metadata observability page_initializer pagination path_resolver paths performance_collector performance_report profile progress retry rich_console sections swizzle text theme_registry theme_resolution thread_local traceback_config traceback_renderer url_normalization url_strategy API Reference Debug ᗢ Caret Down Link Copy URL External Open LLM text Copy Copy LLM text Share with AI Ask Claude Ask ChatGPT Ask Gemini Ask Copilot Module debug.content_migrator Content migration assistant for safe content restructuring. Provides tools to safely move, split, merge, and reorganize content files while maintaining link integrity and generating necessary redirects. Key Features: Preview moves before executing Automatic redirect generation Link update across the site Split large pages into smaller ones Merge related pages Related Modules: bengal.health.validators.links: Link validation bengal.analysis.knowledge_graph: Content relationships bengal.debug.base: Debug tool infrastructure See Also: bengal/postprocess/redirects.py: Redirect handling View source 6 Classes Classes MoveOperation dataclass A planned content move operation. 1 Caret Right A planned content move operation. Attributes Name Type Description source str Source path (relative to content dir) destination str Destination path (relative to content dir) reason str Why this move is happening Internal Methods 1 Caret Right __str__ 0 str Caret Right def __str__(self) -> str Returns str LinkUpdate dataclass A link that needs to be updated. 0 Caret Right A link that needs to be updated. Attributes Name Type Description file_path str File containing the link old_link str Current link target new_link str New link target line int Line number in file context str Surrounding text context Redirect dataclass A redirect rule for moved content. 3 Caret Right A redirect rule for moved content. Attributes Name Type Description from_path str Old URL path to_path str New URL path status_code int HTTP status code (301 permanent, 302 temporary) Methods 3 to_nginx Generate nginx redirect rule. 0 str Caret Right def to_nginx(self) -> str Generate nginx redirect rule. Returns str to_netlify Generate Netlify _redirects format. 0 str Caret Right def to_netlify(self) -> str Generate Netlify _redirects format. Returns str to_apache Generate Apache .htaccess rule. 0 str Caret Right def to_apache(self) -> str Generate Apache .htaccess rule. Returns str MovePreview dataclass Preview of what a move operation would do. 1 Caret Right Preview of what a move operation would do. Attributes Name Type Description operation MoveOperation The move operation being previewed affected_links list[LinkUpdate] Links that would need updating redirects_needed list[Redirect] Redirects that would be generated warnings list[str] Any warnings about the move can_proceed bool Whether the move can safely proceed Methods 1 format_summary Format preview as summary. 0 str Caret Right def format_summary(self) -> str Format preview as summary. Returns str PageDraft dataclass A draft of a new or modified page. Used for split/merge operations to preview changes before applying. 1 Caret Right A draft of a new or modified page. Used for split/merge operations to preview changes before applying. Attributes Name Type Description path str Target path for the page title str Page title content str Page content (markdown) frontmatter dict[str, Any] Page frontmatter source_pages list[str] Original pages this was derived from Methods 1 format_preview Format as preview. 1 str Caret Right def format_preview(self, max_lines: int = 20) -> str Format as preview. Parameters 1 max_lines int Returns str ContentMigrator Tool for safely restructuring content. Helps move, split, merge, and reorganize content while main… 14 Caret Right Tool for safely restructuring content. Helps move, split, merge, and reorganize content while maintaining link integrity and generating necessary redirects. Creation: migrator = ContentMigrator(site=site) Inherits from DebugTool Methods 6 analyze Analyze content structure for migration opportunities. 0 DebugReport Caret Right def analyze(self) -> DebugReport Analyze content structure for migration opportunities. Returns DebugReport — DebugReport with structure analysis preview_move Preview what would happen if a file is moved. 2 MovePreview Caret Right def preview_move(self, source: str, destination: str) -> MovePreview Preview what would happen if a file is moved. Parameters 2 source str Source path (relative to content dir) destination str Destination path Returns MovePreview — MovePreview with affected links and redirects execute_move Execute a previewed move operation. 4 list[str] Caret Right def execute_move(self, preview: MovePreview, update_links: bool = True, create_redirects: bool = True, dry_run: bool = False) -> list[str] Execute a previewed move operation. Parameters 4 preview MovePreview Move preview from preview_move() update_links bool Whether to update links in other files create_redirects bool Whether to generate redirect rules dry_run bool If True, only report what would be done Returns list[str] — List of actions taken (or that would be taken) split_page Split a large page into multiple smaller pages. 3 list[PageDraft] Caret Right def split_page(self, page_path: str, sections: list[str], output_dir: str | None = None) -> list[PageDraft] Split a large page into multiple smaller pages. Parameters 3 page_path str Path to the page to split sections list[str] List of heading names to split at output_dir str | None Optional output directory for new pages Returns list[PageDraft] — List of PageDraft objects for the new pages merge_pages Merge multiple pages into one. 3 PageDraft Caret Right def merge_pages(self, page_paths: list[str], output_path: str, title: str | None = None) -> PageDraft Merge multiple pages into one. Parameters 3 page_paths list[str] Paths to pages to merge output_path str Output path for merged page title str | None Optional title for merged page Returns PageDraft — PageDraft for the merged page generate_redirects Generate redirect rules for moved content. 2 str Caret Right def generate_redirects(self, moves: list[MoveOperation], output_format: str = 'netlify') -> str Generate redirect rules for moved content. Parameters 2 moves list[MoveOperation] List of move operations output_format str Output format (netlify, nginx, apache) Returns str — Redirect rules in requested format Internal Methods 8 Caret Right _find_structure_issues Find potential structure issues in content. 0 list[DebugFinding] Caret Right def _find_structure_issues(self) -> list[DebugFinding] Find potential structure issues in content. Returns list[DebugFinding] _is_in_navigation Check if page is in site navigation. 1 bool Caret Right def _is_in_navigation(self, page: Any) -> bool Check if page is in site navigation. Parameters 1 page Any Returns bool _path_to_url Convert file path to URL. 1 str Caret Right def _path_to_url(self, path: str) -> str Convert file path to URL. Parameters 1 path str Returns str _links_match Check if a link matches a target URL. 2 bool Caret Right def _links_match(self, link: str, target_url: str) -> bool Check if a link matches a target URL. Parameters 2 link str target_url str Returns bool _update_link Update a link to point to new location. 3 str Caret Right def _update_link(self, old_link: str, old_url: str, new_url: str) -> str Update a link to point to new location. Parameters 3 old_link str old_url str new_url str Returns str _update_file_link Update a link in a file. 1 None Caret Right def _update_file_link(self, link_update: LinkUpdate) -> None Update a link in a file. Parameters 1 link_update LinkUpdate _slugify Convert text to URL slug. 1 str Caret Right def _slugify(self, text: str) -> str Convert text to URL slug. Parameters 1 text str Returns str _generate_recommendations Generate recommendations based on analysis. 1 list[str] Caret Right def _generate_recommendations(self, report: DebugReport) -> list[str] Generate recommendations based on analysis. Parameters 1 report DebugReport Returns list[str] ← Previous config_inspector Next → debug List © 2025 Bengal ᓚᘏᗢ window.BENGAL_LAZY_ASSETS = { tabulator: '/bengal/assets/js/tabulator.min.js', dataTable: '/bengal/assets/js/data-table.js', mermaidToolbar: '/bengal/assets/js/mermaid-toolbar.9de5abba.js', mermaidTheme: '/bengal/assets/js/mermaid-theme.344822c5.js', graphMinimap: '/bengal/assets/js/graph-minimap.cc7e42e3.js', graphContextual: '/bengal/assets/js/graph-contextual.440e59c6.js' }; window.BENGAL_ICONS = { close: '/bengal/assets/icons/close.911d4fe1.svg', enlarge: '/bengal/assets/icons/enlarge.652035e5.svg', copy: '/bengal/assets/icons/copy.3d56e945.svg', 'download-svg': '/bengal/assets/icons/download.04f07e1b.svg', 'download-png': '/bengal/assets/icons/image.c34dfd40.svg', 'zoom-in': '/bengal/assets/icons/zoom-in.237b4a83.svg', 'zoom-out': '/bengal/assets/icons/zoom-out.38857c77.svg', reset: '/bengal/assets/icons/reset.d26dba29.svg' }; Arrow Up X -------------------------------------------------------------------------------- Metadata: - Author: lbliii - Word Count: 2019 - Reading Time: 10 minutes