feat: auto-generate blank _index.md files for Hugo by monotykamary · Pull Request #63 · dwarvesf/memo.d.foundation · GitHub
Skip to content

feat: auto-generate blank _index.md files for Hugo#63

Merged
monotykamary merged 1 commit into
mainfrom
feat/auto-generate-index-files
Mar 19, 2025
Merged

feat: auto-generate blank _index.md files for Hugo#63
monotykamary merged 1 commit into
mainfrom
feat/auto-generate-index-files

Conversation

@monotykamary

@monotykamary monotykamary commented Mar 19, 2025

Copy link
Copy Markdown
Collaborator

Summary

This PR implements a new feature to automatically generate blank _index.md files in directories that don't have them in the export path. This helps Hugo properly render content nested in subdirectories without requiring manual creation of these index files.

Changes

  • Added a new generate_missing_index_files function that is called at the end of the directory processing in ExportMarkdown.run
  • Added a new get_all_directories helper function to recursively find all directories in the export path
  • Implemented logic to skip asset folders (both top-level and nested) to avoid creating unnecessary index files
  • Each generated _index.md file includes basic frontmatter with a title derived from the directory name

Why

Hugo requires _index.md files in directories to properly render nested content and list pages. Previously, these files had to be created manually, which could be error-prone and time-consuming.

Testing

  • Manually tested by running the export process and verifying that:
    • Blank _index.md files are generated in directories that didn't have them
    • No _index.md files are generated in asset folders
    • Existing _index.md files are preserved

🤖 Generated with Claude Code

Add functionality to automatically create blank _index.md files in directories
that don't have them in the export path, excluding asset folders.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@monotykamary monotykamary merged commit 6cb82f7 into main Mar 19, 2025
@tieubao tieubao deleted the feat/auto-generate-index-files branch April 2, 2025 16:28
tieubao pushed a commit that referenced this pull request Apr 3, 2025
Add functionality to automatically create blank _index.md files in directories
that don't have them in the export path, excluding asset folders.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-authored-by: Claude <noreply@anthropic.com>
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.

1 participant