Smart Context settings
Smart Context settings control how reviewed source packages are formatted and which optional sources or sections can enter the output.
Where to find these settings in Obsidian
Open Settings -> Community plugins -> Smart Context.
Output settings change the text that Smart Context copies. They do not rewrite the source notes on disk.
Current output controls
The current settings surface exposes:
- Output template for the complete package
- Item template for each source item
- JSON Stringify in Pro for serializer-backed JSON output
- heading filters in Pro
Choose a preset, copy a small package, paste it into a review surface, and inspect the exact structure before using it in a larger workflow.
How a context is structured
A text package combines:
- the output wrapper
- an optional file tree
- one rendered item per selected source or block
- the closing output wrapper
The output template can use {{FILE_TREE}} for a hierarchical source map.
Item templates support:
| Variable | Value |
|---|---|
{{KEY}} |
Full item key or path |
{{ITEM_NAME}} |
File or block name without folder path or extension |
{{TIME_AGO}} |
Relative modified time or Missing |
{{LINK_DEPTH}} |
Link depth, default 0 |
{{EXT}} |
File extension when available |
{{IS_CURRENT}} |
Marker when the item belongs to the active note |
{{FILE_TREE}} marks the first active-note match. Use {{IS_CURRENT}} when every matching item needs a marker.
XML-style default
A simple structured wrapper remains useful for review and downstream tooling.
Context template:
<context>
{{FILE_TREE}}
{{CONTEXT_ITEMS}}
</context>
Item template:
<item loc="{{KEY}}" at="{{TIME_AGO}}" depth="{{LINK_DEPTH}}">
{{ITEM_CONTENT}}
</item>
Markdown and JSON presets
Use the built-in preset selector for Markdown headings or JSON rather than copying an unverified handwritten template from documentation.
For JSON, use JSON Stringify in Pro. Raw {{ITEM_CONTENT}} can contain quotes, backslashes, newlines, and control characters that make a handwritten JSON template invalid. Serializer-backed output avoids unescaped content and trailing-delimiter errors.
Before treating any custom preset as machine-safe, test fixtures containing:
- quotes and backslashes
- multiline text
- triple-backtick code fences
- empty items
- multiple items
- Unicode
- a final item with no invalid trailing delimiter
Heading filters (Pro)
Heading filters include or exclude named sections from copied source items without changing the source note.
- Include keeps only the selected heading sections when they exist in the source.
- Exclude removes the selected heading sections while preserving the remaining content.
- Matching is case-insensitive.
- A directly selected block can provide precise section control when a full note is too broad.
After changing a heading rule, copy a small package and confirm that the intended section is present or absent.
External sources (Pro, desktop)
External-source settings bound desktop filesystem discovery.
Max search depth
Limits how many folder levels Smart Context scans from the selected external root.
Max search items
Caps how many eligible items are retained after a scan.
Use bounded values and ignore patterns for dependencies, builds, caches, generated output, secrets, and unrelated packages.
Troubleshooting
The file tree is missing
Confirm that {{FILE_TREE}} is present in the output template.
Linked notes are hard to distinguish
Add {{LINK_DEPTH}} to the item template so direct and traversed items remain visible.
The output is too large
- Reduce link depth.
- Remove unnecessary sources or blocks in Builder.
- Shorten wrappers.
- Remove the file tree only when source hierarchy is not required.
JSON output fails to parse
Use JSON Stringify instead of a handwritten JSON template, then test the pasted result with a JSON parser before downstream automation.