Import and export
Template rules live in a
.jsonor.jsfile and come in through the "Profiles" section of the settings. Importing is an overwrite-by-id update with whole-file validation: all of it applies, or none of it does.
File format
{
"id": "wide",
"name": "wide",
"floatAlignment": "alternate",
"rules": [
{ "ratioRange": "[0.75,1.35]", "width": 0.68, "layout": "auto", "side": "auto" },
{ "ratioRange": "(1.35,5]", "width": "0.55 + 0.1 * Math.log(r)", "layout": "auto", "side": "auto" }
]
}Save it as .json and pick it in Settings → AutoGallery → Profiles → Import profiles. The file may also contain an array, importing several templates at once.
| Field | Optional | When omitted |
|---|---|---|
id | yes | the file name is used |
name | yes | the id is used |
floatAlignment | yes | alternate |
rules | yes | an empty array is treated as auto |
Overwrite semantics
| Situation | Result |
|---|---|
same id as an existing template | replaced entirely |
| templates not mentioned in the file | kept as they are |
id is the built-in auto | always skipped, never overwritten |
| a rule has an invalid expression | that rule is dropped silently |
The last row deserves its own sentence: an invalid rule does not raise an error, it just disappears. After importing, count the rules in the same panel against the file — a smaller number means an expression failed validation.
Whole-file validation
If any template in the file is invalid, the whole file is rejected and nothing is written. There is no half-applied state where the first two templates took effect and the last two did not.
External profile file
The externalProfilePath setting can point at a configuration file outside the vault, for teams that want templates to travel with a repository rather than with a personal vault:
- The path may be absolute or relative to the vault root.
- If the file is missing or unreadable, the last successfully imported configuration stays — templates are never wiped.
- Export can write to that path or download to the system downloads folder.
Export
"Export all" writes every current template into one file in exactly the import format, so an exported file can be edited and imported straight back.
Validation and troubleshooting
| Symptom | Cause | Fix |
|---|---|---|
| "No layout templates to import" | the file only contains auto, or a field name is wrong | check that rules is an array |
| Import succeeds but rules are missing | an expression used a bare min / max | write Math.min / Math.max |
| Nothing changed after importing | no route uses the template | see Routing |
| One image still ignores the template | it has its own ag:width | remove the parameter, or accept that parameters win |
Next
- Layout templates: how to write the rules
- Frontmatter routing: how to make a template apply