Obsidian Share

Part of Obsidian guides

There are times I want to create a public link to one of my notes, without having an entire "digital garden" through Obsidian Publish.

Enter Obsidian Share. To share a page, just run a single Templater script. Templater is also optional - it's plain Javascript so you can launch it from anywhere.

This page you're currently reading was published through Obsidian Share.

Features

🔹 Uploads using your current theme, along with all your options and custom CSS. I'm using Primary in this document.

🔹 Local and remote image support:

🔹 Supports anything that Obsidian Reading mode does, like rendered Dataview queries or any plugins that show content inside the normal Reading view.

Here's an example inline Dataview query. It will be correctly rendered when sharing:

The answer is `= 7 + 8`!

The answer is 15!

🔹 Supports callouts with full styling:

Warning

Contents may be epic 😵

🔹 Filenames are anonymised through hashing so people can't discover your other shared notes.

🔹 If your shared note links to another note which is also shared, that link will also function on the shared webpage. Example: Some other document

🔹 Frontmatter is stripped on upload to avoid leaking unwanted data.

Configuration options

  • YAML_FIELD - The frontmatter field prefix for storing share link and updated time. A value of share will create frontmatter fields of share_link and share_updated.
  • WIDTH - The width of the note body, in pixels.
  • SHOW_FOOTER - Turn the "Published with Obsidian Share" footer on or off. You can also replace the footer text with anything you want.

Installation with Templater

I use Templater solely because it's an easy way to launch a script. You don't actually need Templater for this to work, it's just plain Javascript.

  1. Install Templater from the Community Plugins.
  2. Copy the script contents from here.
  3. Create a new template, with this format:
  <%*
  // Paste the script contents here
  %> 
  1. Go to any note and execute the script the same as you would any Templater template.

Usage

The first time a file is shared, the script will automatically upload all the theme styles. The next time you share the same file, it will ignore the CSS since it's already been uploaded. If you want to force the theme CSS to re-upload, just remove the share_link property from your frontmatter.

Published with Obsidian Share