Skip to content

Support docs without frontmatter #4425

Closed

Description

@ashutoshkumars

Hi,
I was trying to find a way since docuaurus ver 1 to find a way I could publish md files without making any change to conform them to frontmatter, I wanted to get rid of putting "id" in hundreds of files. In ver 2, that problem was solved. But i find that since my filenaming is in format word1_word2_word3.md (eg:"system_design_documents.md", i do need to add frontmatter to take care of 2 things:

  • clean sidelabels ("System Design Documents" looks better than "system_design_documents")
  • clean title ( I already had all the documents starting with legible H1's.

For handling these 2 scenarios, i find myself eventually editing all the files or writing a small hack to add these elements to the md files.

Can we have a feature wherein we can have the starting H1 of the document be treated as doc title ?

Thanks,
ashutosh

Activity

  1. added
    feature
    status: needs triage
    on Mar 13, 2021
  2. slorber commented on Mar 15, 2021

    @slorber
    Collaborator

    Frontmatter is optional: what about naming the doc System Design Documents.md ?

    If there is a md file with both a frontmatter title and a # title, which wins?

  3. ashutoshkumars commented on Mar 16, 2021

    @ashutoshkumars
    Author

    Adding space in filename breaks the navigation urlencodes the url which somehow don't look clean (although its a subjective opinion)

    If there is a md file with both a frontmatter title and a # title, which wins?

    The "# title" never makes it. Even if there is no frontmatter title, the "# title" is never set as title, because docusaurus doesnt process any markup content for meta purposes.

  4. slorber commented on Mar 16, 2021

    @slorber
    Collaborator

    Adding space in filename breaks the navigation urlencodes the url which somehow don't look clean (although its a subjective opinion)

    image

    image

    You mean you don't like the %20 here?

    I think we should just slugify this filename (ie you would end up with /my-test).

    This would also fix the error when using filenames with special chars:

    image

    The "# title" never makes it. Even if there is no frontmatter title, the "# title" is never set as title, because docusaurus doesnt process any markup content for meta purposes.

    image

    image

    The issue is that we end up with the title that is inferred from the filename instead of the # Hello title in the doc.

    My question was more related to the behavior we actually want if we fix your issue, considering the edge cases where there is potentially a title frontmatter and multiple h1 headings in the markdown document.

    My idea is:

    • frontmatter always win
    • if no frontmatter and an h1 heading is at the very top, we use it as title instead of the filename
    • if no frontmatter and an h1 heading is found in the middle of a doc, we ignore it
  5. changed the title [-]Zero-edit frontmatter MD file for publishing[/-] [+]Support docs without frontmatter[/+] on Mar 16, 2021
  6. removed
    status: needs triage
    on Mar 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions