Skip to content

Instantly share code, notes, and snippets.

@Boettner-eric
Last active February 12, 2026 17:14
Show Gist options
  • Select an option

  • Save Boettner-eric/e15deae15ccae8605c5fcfc953e55de2 to your computer and use it in GitHub Desktop.

Select an option

Save Boettner-eric/e15deae15ccae8605c5fcfc953e55de2 to your computer and use it in GitHub Desktop.
Toggle frontmatter in obsidian source and reading views.
/*
Hide all frontmatter by default (can still view properties in right pane)
To view/edit add `show-frontmatter` class to cssclasses or toggle with Snippet Commands plugin
*/
/* Hide frontmatter preview for reading view */
.markdown-preview-view:not(.show-frontmatter) div.metadata-container {
display: none; margin: 0px; height: 0px; visibility: hidden;
}
/* Hide frontmatter in source mode - hide lines containing frontmatter markers */
.markdown-source-view:not(.show-frontmatter) .cm-line:has(.cm-hmd-frontmatter) {
display: none;
height: 0;
line-height: 0px;
margin: 0;
padding: 0;
}
/* Hide entire frontmatter block including content between --- markers */
.markdown-source-view:not(.show-frontmatter) .cm-line .cm-hmd-frontmatter {
display: none;
height: 0;
line-height: 0;
}
/* Also hide the fold indicator for frontmatter lines */
.markdown-source-view:not(.show-frontmatter) .cm-line:has(.cm-hmd-frontmatter) .cm-fold-indicator {
display: none;
}
@Boettner-eric
Copy link
Author

** Updated ** - made frontmatter hidden by default and added a class for showing in individual notes. This pairs better with the Snippet Commands plugin and pollutes fewer notes with cssclasses.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment