What I’m trying to do
I created a template that works fine.
BUT when I close the file or shut down Obsidian, when I reopen it says there is a syntax error.
Things I have tried
I had assumed I accidentally hit an errant key and put in some junk. I tried fixing it but nothing worked. So I copied all the code out to a flat text editor, deleted everything in my template, then added the code back in one line at a time. It worked fine again. Same code.
I thought I had everything fixed but then the same thing happened again the next time I closed and reopened the file.
The error that’s flagged is related to some nunjucks code in the frontmatter. I have a suspicion there may be some automatic unicode conversion on open going - on or something along those lines - but I’ll be darned if I can find a setting anywhere for that.
Here are my specifics:
Obsidian 1.6.5
Enabled Plugins:
- Advanced Tables
- Advanced URI
- Auto Link Title
- Better File Link
- Book Search
- BRAT
- Calendar
- Callout Manager
- Citations
- Commander
- Dataview
- Excalibrain
- Excalidraw
- Highlightr
- Hotkey Helper
- Hotkeys++
- Hover Editor
- Iconize
- Link Favicons
- List Callouts
- Meta Bind
- Natural Language Dates
- Note Gallery
- Note Refactor
- Pandoc Plugin
- Pane Relief
- Paste URL into selection
- Periodic Notes
- Quick Switcher++
- QuickAdd
- Raindrop Highlights
- Simple Embeds
- Snippet Downloader
- Sortable
- Style Settings
- Supercharged Links
- Tag Wrangler
- Tasks
- Templater
- Text Format
- Update time on edit
- Wikipedia
- Zoom
- Zotero Integration
Error message: “Syntax error. Your frontmatter is invalid”
Source code:
---
in:
- "[[Papers]]"
related:
- "[[Domains]]"
title: "{{title}}"
authors:
- "{{authors}}"
publicationTitle: "{{publicationTitle}}"
journalAbbreviation: "{{journalAbbreviation}}"
year: '{{date | format("YYYY")}}'
volume: "{{volume}}"
issue: "{{issue}}"
pages: "{{pages}}"
paperType: "{{itemType}}"
abstract: "{{abstractNote}}"
doi: "{{DOI}}"
issn: "{{ISSN}}"
url: "{{url}}"
accessDate: '{{accessDate | format("YYYY-MM-DD")}}'
created: '{{exportDate | format("YYYY-MM-DD")}}'
citekey: "{{citekey}}"
tags: {% if tags.length > 0 -%} {%- for t in tags -%} {%- set newTag = t.tag | lower | replace(" ", "-") %} {{newTag}} {%- endfor %} {%- endif %}
aliases:
- "{{title}}"
- "{{citekey}}"
---
{% persist "DMW (Cornell Notes++)" %}
{% if isFirstImport -%}
## {{title}}
### {{authors}}
> [!User] ## **DMW (Cornell Notes++)**
#### Questions/Cues
-
#### Notes
-
#### Summary
-
#### Relate
-
> [!Shrink]+ ### Abstract
> {{abstractNote}}
> [!Bookmark]+ ### Author-Defined Tags
> {% if tags -%}
> {% for t in tags %}
> - {% set adTag = t.tag | lower | replace(" ", "-") %} ==[[{{adTag}}]]==
> {% endfor %}
> {%- endif %}
{% endif -%}
{% endpersist %}
> [!Album]+ ### Zotero
> #### *Annotations*
> {% for annotation in annotations %}
> {%- if annotation.annotatedText %}
> - "{{annotation.annotatedText}}", [Page {{annotation.page}}]({{annotation.desktopURI}})
> {%- endif %}
> {%- if annotation.imageRelativePath %}
> - ![[{{annotation.imageRelativePath}}]] [Page {{annotation.page}}]({{annotation.desktopURI}})
> {%- if annotation.allTags %}
> {% for tag in annotation.tags %}
> - {%- set annoTag = "" ~ tag.tag | lower | replace(" ", "-") %} ==[[{{annoTag}}]]==
> {%- endfor %}
> {%- endif %}
> {%- endif %}
> {% if annotation.comment %}
> - {{annotation.comment}}
> {%- if annotation.allTags %}
> {% for tag in annotation.tags %}
> - {%- set annotTag = "" ~ tag.tag | lower | replace(" ", "-") %} ==[[{{annotTag}}]]==
> {%- endfor %}
> {%- endif %}
> {% endif %}
> {%- endfor %}
> #### *Entry Notes*
> {%- if notes | first -%}
> {% for note in notes %}
> - {{note.note}}
> {%- endfor %}
> {% else %}
> - *none defined*
> {%- endif %}
> #### *Related*
> {%- if relations | first -%}
> {% for relation in relations %}
> - related: {{relation.citekey}}
> {%- endfor -%}
> {% else %}
> - *none defined*
> {%- endif %}
> #### *Links*
> - [Zotero Listing]({{desktopURI}})
> [!Newspaper]+ ### APA Bibliography Entry
> {{bibliography}}
{% for c in creators %}
{% set fullName = c.lastName + ", " + c.firstName %}
<%*
if (!tp.file.find_tfile("{{fullName}}")) {
await tp.file.create_new("{{bibliography}}", "{{fullName}}" + ".md", false, "+");
}
%>
{% endfor %}