Advanced Exclude

approved

by Michael Naumov

Enhances the Excluded files setting bringing gitignore syntax. - This plugin has not been manually reviewed by Obsidian staff.

65 stars14,092 downloadsUpdated 11d agoMIT

Advanced Exclude

Buy Me a Coffee GitHub release GitHub downloads Coverage: 100%

This is a plugin for Obsidian that enhances the Excluded files setting bringing gitignore syntax.

Obsidian has Files and links > Excluded files setting, but it is not as useful, because the excluded files are still present in the Files pane, appear in Backlinks pane, etc.

The plugin adds the following features:

  • Configure ignore patterns using gitignore syntax.
  • .obsidianignore file for manual editing.
  • Support ignore patterns from .gitignore file.
  • Reuse existing Files and links > Excluded files setting in string/regexp format.
  • Optionally hide folders left empty by exclusion via the Hide empty folders setting. When every file inside a folder is excluded, the folder is hidden too, cascading up through parent folders whose whole subtree became empty. Genuinely empty folders (with no files at all) stay visible.

[!WARNING]

The plugin makes Obsidian behave like the ignored files do not exist. This might affect features like Obsidian Sync, Obsidian Publish, etc.

Ensure you configured the plugin correctly to avoid data loss.

Demo vault

A demo vault with usage examples ships with every release. You can access it via any of the following:

  1. Running the Advanced Exclude: Open demo vault command.
  2. Downloading advanced-exclude-demo-vault-<version>.zip (<version> is the release version) from the Releases.
  3. Browsing its source in demo-vault/ in this repository.

Pattern examples

Patterns use gitignore syntax. A few common recipes:

Ignore a folder and everything under it:

Archive/

Ignore all files with a given extension, anywhere in the vault:

*.png

Ignore everything except a few file types (a whitelist). This is the idiom most people get wrong: once * ignores everything, you must re-include directories with !*/ before a negated file rule can match inside them — otherwise the files stay ignored because their parent folder is still excluded:

# Ignore everything...
*
# ...but keep folders traversable so the rules below can reach into them...
!*/
# ...and re-include these file types.
!*.md
!*.canvas
!*.base

Whitelist specific folders instead of file types:

*
!Journal/
!Journal/**
!Templates/
!Templates/**

[!NOTE]

The !*/ (or !Folder/) line is required by gitignore itself: "It is not possible to re-include a file if a parent directory of that file is excluded." Re-including the directory is what lets the later !... file rules take effect.

See the official gitignore pattern format for the full syntax.

Installation

The plugin is available in the official Community Plugins repository.

Beta versions

To install the latest beta release of this plugin (regardless if it is available in the official Community Plugins repository or not), follow these steps:

  1. Ensure you have the BRAT plugin installed and enabled.
  2. Click Install via BRAT.
  3. An Obsidian pop-up window should appear. In the window, click the Add plugin button once and wait a few seconds for the plugin to install.

Debugging

By default, debug messages for this plugin are hidden.

To show them, run the following command in the DevTools Console:

window.DEBUG.enable('advanced-exclude');

For more details, refer to the documentation.

Support

Buy Me A Coffee

My other Obsidian resources

See my other Obsidian resources.

License

© Michael Naumov

For plugin developers

Search results and similarity scores are powered by semantic analysis of your plugin's README. If your plugin isn't appearing for searches you'd expect, try updating your README to clearly describe your plugin's purpose, features, and use cases.