Skip to content

[Feature]: Fallback to H1 Heading for Page Title #755

Description

@kmarekspartz

What problem are you trying to solve?

Title: Feature Request: Fall back to first H1 heading for document title when YAML frontmatter title is missing

Context

In many markdown repositories (such as personal wikis, Obsidian vaults, or documentation sets), documents do not always contain a YAML frontmatter block with a title key. For example, simple list files or notes imported from standard markdown editors often start directly with an H1 heading (e.g., # Someday / Open Loops) and omit frontmatter completely.

Current Behavior

When the OpenKnowledge server parses a document lacking a title key in its YAML frontmatter, it defaults to using the document path or slug (e.g., projects/make-alternate-universe-uno or resources/someday) as the title.

This raw path is then displayed in:

  • Search Results: The search headers show the slug/path rather than a human-readable title.
  • Directory Enriched Metadata: Running directory commands like ls -A returns path-based titles under the Referenced files section.
  • Link Autocompletions / Index lists: Graph visualizations and listings feel less polished.

Proposed Enhancement

If title is missing from the YAML frontmatter, the OpenKnowledge parser should fall back to the first H1 heading found in the document body (e.g., # Document Title).

The title resolution hierarchy should be:

  1. title: key in YAML frontmatter (highest priority)
  2. First # H1 Heading in the markdown body
  3. Filename / Slug (fallback)
  4. Full relative path (final fallback)

Benefits

  • Clean UI & Search: Ensures search results and lists remain human-readable even for simple notes or legacy logs that don't need metadata frontmatter.
  • Matches Modern SSG Standards: Pragmatic and aligned with conventions used by Nextra, Astro, and Docusaurus.

Proposed solution

No response

Area

Editor

Alternatives considered

No response

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions