# Personal Readwise Obsidian Export Format ## Metadata **Status**:: #x **Zettel**:: #zettel/permanent **Created**:: [[2022-09-26]] **Topic**:: [[♯ Readwise]] **Kind**:: #personal-customization ## Customization [Customize in Readwise](https://readwise.io/export/obsidian/preferences) ### File Name [Documentation →](https://help.readwise.io/article/126-how-can-i-customize-the-readwise-to-obsidian-export#file-name) I added the first author to the name. Multiple authors are separated by `,<Space>` or `<Space>&<Space>`. ```jinja2 {% if author %}{{ author.split(' & ')[0].split(', ')[0]|replace('_', ' ')|replace(':', '')|replace('?', '')|replace('"', '')|replace('/', '')|replace('|', '')|replace('*', '')|replace('<', '')|replace('>', '')|replace('#', ' ') }}{% if ' & ' in author or ', ' in author %} et al.{% endif %} - {% endif %}{{title|replace('#', ' ')}} (Highlights) ``` ### Page Title [Documentation →](https://help.readwise.io/article/126-how-can-i-customize-the-readwise-to-obsidian-export#title) Keep title and file name consistent. ```jinja2 # {% if author %}{{ author.split(' & ')[0].split(', ')[0]|replace('_', ' ')|replace(':', '')|replace('?', '')|replace('"', '')|replace('/', '')|replace('|', '')|replace('*', '')|replace('<', '')|replace('>', '')|replace('#', ' ') }}{% if ' & ' in author or ', ' in author %} et al.{% endif %} - {% endif %}{{title|replace('#', ' ')}} (Highlights) ``` ### Page Metadata [Documentation →](https://help.readwise.io/article/126-how-can-i-customize-the-readwise-to-obsidian-export#metadata) [[Obsidian Dataview Plugin|Dataview]] style metadata. ```jinja2 {% if image_url -%} ![rw-book-cover|256]({{image_url}}) {% endif -%} ## Metadata **Review**:: [readwise.io](https://readwise.io/bookreview/{{ book_id }}) **Source**:: #from/readwise #from/{{ source|lower|replace(' ', '-') }} **Zettel**:: #zettel/fleeting **Status**:: #x **Authors**::{% if author %} [[{{ author|replace('_', ' ')|replace(', ', ']], [[')|replace(' & ', ']], [[') }}]]{% endif %} **Full Title**:: {{full_title}} **Category**:: #{{category}} #readwise/{{category}} **Category Icon**:: {{ "📚" if category == "books"}}{{"📰" if category == "articles"}}{{"🐦" if category == "tweets"}}{{"🎙" if category == "podcasts"}} {% if document_tags -%} **Document Tags**::{% for tag in document_tags %} #{{tag}}{% endfor %} {% endif -%} {% if url -%} **URL**:: [{{url.split('://')[-1].split('/')[0]}}]({{url}}) **Host**:: [[{{url.split('://')[-1].split('/')[0]}}]] {% endif -%} **Highlighted**:: [[{{last_highlighted_date|date('Y-m-d')}}]] {% if date -%} **Created**:: [[{{date|date('Y-m-d')}}]] {% endif -%} {% if document_note %} ## Note {{ document_note|replace('↩︎', '') }} {% endif -%} ``` ### Highlights Header [Documentation →](https://help.readwise.io/article/126-how-can-i-customize-the-readwise-to-obsidian-export#header) ```jinja2 {% if is_new_page %} ## Highlights {% elif has_new_highlights -%} <!-- New highlights added {{date|date('F j, Y')}} at {{time}} --> {% endif -%} ``` ### Highlight [Documentation →](https://help.readwise.io/article/126-how-can-i-customize-the-readwise-to-obsidian-export#highlight) I added the anchor `^{{highlight_id}}` to allow [linking to a specific highlight in Obsidian](https://help.obsidian.md/How+to/Link+to+blocks#Link+to+blocks). [[Readwise Note Format Cheatsheet]] ```jinja2 {%- if highlight_text|length > 1 -%} - {% if highlight_text.startswith('↩︎') %}↩︎{% else %}{{ highlight_text.split('↩︎', 1)[0]|indent(1)|replace('␣', ' ') }}{% endif %}{% if highlight_location and highlight_location_url %} ([{{highlight_location}}]({{highlight_location_url}})){% elif highlight_location %} ({{highlight_location}}){% endif %} {% if highlight_note and highlight_note.startswith('^') %}{{highlight_note.split('\n',1)[0]}}{% else %} ^{{highlight_id}}{% endif %}{% if '↩︎' in highlight_text %} {{ highlight_text.split('↩︎', 1)[1]|trim|indent(1)|replace('␣', ' ') }} {% endif %}{% if highlight_tags %} {% for tag in highlight_tags %}#{{tag}} {% endfor %} {% endif %}{%- if highlight_note and ((not highlight_note.startswith('^')) or highlight_note.find('\n') >= 0)%} {% if not highlight_tags %} {% endif %} {% if highlight_note.startswith('^') -%} {{ highlight_note.split('\n',1)[1]|trim|replace('\n∎', '\n')|indent(1)|replace('␣', ' ') }} {%- else -%} {{ highlight_note|trim|replace('\n∎', '\n')|indent(1)|replace('␣', ' ') }} {%- endif %} {% endif -%} {% elif highlight_note %} {{ highlight_note.split('\n')|map('trim')|join('\n')|replace('\n∎', '\n')|replace('␣', ' ') }} {%- endif %} ``` Since the highlight is in the list, and the location and the anchor are appended to the end, the format is malformed if the highlight is a multiple line markdown block. I add a line `↩︎` before and `∎` after to fix the format. ^highlight-marks I also use `␣` to [[Keep the Leading Whitespaces in Readwise Highlights and Notes]]. The following is an example of how to format a code block with indentations in Readwise. ~~~markdown ↩︎ ```ruby def hello(name): ␣␣puts "Hello, #{name}" end ``` ∎ ~~~ ### YAML Front Matter [Documentation →](https://help.readwise.io/article/126-how-can-i-customize-the-readwise-to-obsidian-export#yaml-front-matter) Disable Obsidian Publish when there is a document tag `private`. ```jinja2 {%- if 'private' in document_tags %} publish: false {% endif -%} {% if image_url -%} cover: "{{image_url}}" {% endif -%} ``` ### Sync Notification [Documentation →](https://help.readwise.io/article/126-how-can-i-customize-the-readwise-to-obsidian-export#notification) I use level 1 heading so that I can use Note composer to [Extract heading into a new note](https://help.obsidian.md/Plugins/Note+composer#Extract+note). ```jinja2 # Readwise Sync {{date|date('Y-m-d')}} ## Metadata **Source**:: #from/readwise **Created**:: [[{{date|date('Y-m-d')}}]] **Highlights**:: {{num_highlights}} **Files**: {{num_books}} ## Files {% for book in books %}- {{ book.num_highlights_added}} in [[{% if book.author %}{{ book.author.split(' & ')[0].split(', ')[0]|replace('_', ' ')|replace(':', '')|replace('?', '')|replace('"', '')|replace('/', '')|replace('|', '')|replace('*', '')|replace('<', '')|replace('>', '')|replace('#', ' ') }}{% if ' & ' in book.author or ', ' in book.author %} et al.{% endif %} - {% endif %}{{ book.title|replace(':', '')|replace('?', '')|replace('"', '')|replace('/', '')|replace('|', '')|replace('*', '')|replace('<', '')|replace('>', '')|replace('#', ' ') }} (Highlights)]] {% endfor %} ```