Organize Files

Organize Files

Directory Structure

By default, Hugo searches for Markdown files in the content directory, and the structure of the directory determines the final output structure of your website. Take this site as an example:

    • _index.md
      • _index.md
      • getting-started.md
        • _index.md
        • organize-files.md
      • _index.md
      • post-1.md
    • _index.md
    • .gitignore
    • LICENSE
    • Makefile
    • README.md
    • vanityURLS.conf
      • _index.md
      • getting-started.md
        • _index.md
        • organize-files.md
      • _headers
      • lnk
      • validateURL
  • ℹ️
    It is recommended to keep the sidebar not too deep. If you have a lot of content, consider splitting them into multiple sections.

    Each of the _index.md files is the index page for the corresponding section. The other Markdown files are regular pages.

    content
    ├── _index.md // <- /
    ├── docs
    │   ├── _index.md // <- /docs/
    │   ├── getting-started.md // <- /docs/getting-started/
    │   └── guide
    │       ├── _index.md // <- /docs/guide/
    │       └── organize-files.md // <- /docs/guide/organize-files/
    └── blog
        ├── _index.md // <- /blog/
        └── post-1.md // <- /blog/post-1/

    Layouts

    Hextra offers three layouts for different content types:

    Layout Directory Features
    docs content/docs/ Ideal for structured documentation, same as this section.
    blog content/blog/ For blog postings, with both listing and detailed article views.
    default All other directories Single-page article view without sidebar.

    To customize a section to mirror the behavior of a built-in layout, specify the desired type in the front matter of the section’s _index.md.

    content/my-docs/_index.md
    ---
    title: My Docs
    cascade:
      type: docs
    ---

    The above example configuration ensures that the content files inside content/my-docs/ will be treated as documentation (docs type) by default.

    Sidebar Navigation

    The sidebar navigation is generated automatically based on the content organization alphabetically. To manually configure the sidebar order, we can use the weight parameter in the front matter of the Markdown files.

    content/docs/guide/_index.md
    ---
    title: Guide
    weight: 2
    ---