@@ -86,8 +86,7 @@ def convert_documentation(self,
8686 return False
8787
8888 # Convert content files
89- conversion_stats = self ._convert_content_files (
90- devsite_structure , source_path , output_path , dry_run ,
89+ conversion_stats = self ._convert_content_files (source_path , output_path , dry_run ,
9190 incremental )
9291
9392 # Convert static assets
@@ -140,8 +139,10 @@ def _create_output_structure(self, output_path: str) -> None:
140139 dir_path .mkdir (parents = True , exist_ok = True )
141140 logger .debug (f"Created directory: { dir_path } " )
142141
143- def _convert_content_files (self , devsite_structure : Dict , source_path : str ,
144- output_path : str , dry_run : bool ,
142+ def _convert_content_files (self ,
143+ source_path : str ,
144+ output_path : str ,
145+ dry_run : bool ,
145146 incremental : bool ) -> Dict :
146147 """Convert all content files from Devsite to Hugo format"""
147148 conversion_stats = {
@@ -172,9 +173,10 @@ def _convert_content_files(self, devsite_structure: Dict, source_path: str,
172173 category_path = self ._get_category_path (relative_path )
173174
174175 # Convert file
176+ if category_path == Path ("how-to-guides" ):
177+ raise Exception (f"{ category_path } is not a valid category. Please update config.yaml to use 'docs' or 'tutorials' instead." )
175178 if self ._convert_single_file (
176- md_file , output_dir / 'content' / category_path ,
177- devsite_structure , dry_run ):
179+ md_file , output_dir / 'content' / category_path , dry_run ):
178180 conversion_stats ['converted_files' ] += 1
179181 else :
180182 conversion_stats ['error_files' ] += 1
@@ -193,6 +195,11 @@ def _get_category_path(self, relative_path: Path) -> Path:
193195 return relative_path
194196
195197 section_name = parts [0 ]
198+
199+ # Orphan file like "help.md" -> put under Reference
200+ if len (parts ) == 1 and parts [0 ] == "help.md" :
201+ logger .info (f"Orphan file { parts [0 ]} detected, placing under 'reference' category" )
202+ return Path ("docs" ) / Path ("reference" ) / parts [0 ]
196203
197204 # Look up the category for this section
198205 if section_name in self .config ['content_mapping' ]:
@@ -201,12 +208,9 @@ def _get_category_path(self, relative_path: Path) -> Path:
201208
202209 # Return path with category prefix
203210 return Path (category_type ) / relative_path
204-
205- # Default to original path if no mapping found
206- return relative_path
211+ raise Exception (f"No category mapping found for section '{ section_name } ', using original path" )
207212
208- def _convert_single_file (self , source_file : Path , output_file : Path ,
209- devsite_structure : Dict , dry_run : bool ) -> bool :
213+ def _convert_single_file (self , source_file : Path , output_file : Path , dry_run : bool ) -> bool :
210214 """Convert a single markdown file from Devsite to Hugo format"""
211215 try :
212216 # Read source file
@@ -217,9 +221,7 @@ def _convert_single_file(self, source_file: Path, output_file: Path,
217221 frontmatter , body = self ._parse_markdown_file (content )
218222
219223 # Convert frontmatter to Hugo format
220- hugo_frontmatter = self ._convert_frontmatter (
221- frontmatter , source_file , devsite_structure )
222-
224+ hugo_frontmatter = self ._convert_frontmatter (frontmatter = frontmatter )
223225 # Extract title from H1 if not present in frontmatter
224226 title_from_h1 = None
225227 h1_match = re .search (r'^# (.+)$' , body , re .MULTILINE )
@@ -277,8 +279,7 @@ def _parse_markdown_file(self, content: str) -> Tuple[Dict, str]:
277279
278280 return {}, content
279281
280- def _convert_frontmatter (self , frontmatter : Dict , source_file : Path ,
281- devsite_structure : Dict ) -> Dict :
282+ def _convert_frontmatter (self , frontmatter : Dict ) -> Dict :
282283 """Convert Devsite frontmatter to Hugo format"""
283284 hugo_frontmatter = {}
284285
@@ -296,7 +297,6 @@ def _convert_frontmatter(self, frontmatter: Dict, source_file: Path,
296297 hugo_frontmatter [hugo_field ] = frontmatter [devsite_field ]
297298
298299 # Add Hugo-specific fields
299- hugo_frontmatter ['type' ] = 'docs' # Default to docs template
300300 hugo_frontmatter ['weight' ] = frontmatter .get ('weight' , 1 )
301301
302302 # Add title from H1 if not present in frontmatter
@@ -309,10 +309,6 @@ def _convert_frontmatter(self, frontmatter: Dict, source_file: Path,
309309 if 'title' in hugo_frontmatter and 'linkTitle' not in hugo_frontmatter :
310310 hugo_frontmatter ['linkTitle' ] = hugo_frontmatter ['title' ]
311311
312- # Add date if not present
313- if 'date' not in hugo_frontmatter :
314- hugo_frontmatter ['date' ] = '2024-01-01'
315-
316312 return hugo_frontmatter
317313
318314 def _convert_body_content (self , body : str ) -> str :
@@ -640,10 +636,6 @@ def _generate_hugo_config(self, output_path: str) -> None:
640636 """Generate Hugo configuration file"""
641637 self .hugo_generator .generate_config (output_path )
642638
643- def _generate_layouts (self , output_path : str ) -> None :
644- """Generate Hugo layout templates"""
645- self .hugo_generator .generate_layouts (output_path )
646-
647639 def _generate_section_indices (self , devsite_structure : Dict ,
648640 output_path : str ) -> None :
649641 """Generate _index.md files for Hugo sections"""
0 commit comments