Obsidian Mkdocs Publisher : A free publish alternative

Mkdocs Obsidian

Mkdocs Obsidian is an association between a python script and a Material mkdocs template to get a personal wiki site based on your Obsidian Vault.

Documentation
My blog (fr)

Screenshot




You can also use an Obsidian Plugin :

6 Likes

Thanks for writing in details like this. It helps and gives me the motivation to try your setup.

Please teach me if I didnt understand correctly the 2 things as follows.

  1. After having installed mkdocs-material, in order to publish notes I have now 2 options:

    • manually copy notes that I want to publish from my Obsidian vault folder to my folder /docs located in my repo folder
    • or use your script mkdocs-obsidian to do the task programmatically.
  2. In order to make mkdocs-obsidian work for selective publishing, I need to specify an attribute share: true in the frontmatter of every notes that I want to publish.

I think you entirely understand!
The share: true key is when you want to share multiple file. But, if you want to just publish one file, you need to use obs2mk --f "Path/to/the/file"

Thanks for sharing this info this is useful keep it up.

1 Like

I was just scrolling and found some good information thanks for sharing this amazing post keep posting.

1 Like

Also, as I create MetaCopy to quickly copy a link from this workflow, here is a little tutorial to use it as I do.

Here is a demo

With that, you avoid to edit your source file and you can share a link as notion !

Hello
I added new options, including sharing the entire vault and mobile.

Mobile is intended to be used with IOS shortcuts.

usage: obs2mk [-h] [--git | --mobile] [--meta] [--keep] [--config]
                   [--force] [--filepath FILEPATH | --ignore]

Create file in docs and relative folder, move image in assets, convert
admonition code_blocks, add links and push.

optional arguments:
  -h, --help            show this help message and exit
  --git, --g, --G       No commit and no push to git
  --mobile, --shortcuts, --s, --S
                        Use mobile shortcuts fonction without push.
  --meta, --m, --M      Update the frontmatter with link
  --keep, --k, --K      Keep deleted file from vault and removed shared file
  --config, --c, --C    Edit the config file
  --force, --d, --D     Force conversion - only work if path not specified
  --filepath FILEPATH, --f FILEPATH
                        Filepath of the file you want to convert
  --ignore, --ignore-share, --no-share, --i, --vault
                        Convert the entire vault without relying on share
                        state.

Share the entire vault

Using the command --ignore will ignore the share state : you can share your entire vault using that, whatever the state is. By default, it will not overwrite file already exist (and not different), so the --force option can also be used.

usage: obs2mk [-h] [--git | --mobile] [--meta] [--keep] [--config] [--force] [--ignore]

Mobile option

The mobile option is similar to the git option but with some nuance. When used to publish a single file, you can use only the file name, without the path.

:warning: Be careful though, in case you have several files with the same name, the script will take the first file found.

This option can be used, especially with the “Shortcuts” application on IOS, to share a file directly from the share sheet.

One file usage : obs2mk --mobile --f "filename"
All file usage : obs2mk --mobile

Mobile supports all previous option, including --ignore.

1 Like

As I was bored, I updated the script to use Python Rich. So, now you have more information when you share all-share vault !
script_demo

1 Like

Hello everyone!
The template now supports tooltip. It’s a fork, waiting for a pull request.

To install it, use pip install git+git://github.com/Mara-Li/mkdocs-tooltipster-links-plugin

I adjust the CSS to be cool with the theme.

01-18-2022_22-53

If I success to contact the original author of the plugin (who is an Obsidian User !) I think I will use it to, also, add real embed citation in the blog.
After that, I think the blog can be considered as complete.

One day, maybe, it will be a mkdocs plugin and everything will be converted during the build :’).

1 Like

Okay !
I create a new mkdocs plugin to embed file in mkdocs !

I updated the template + the script to add the support of embed file like in obsidian !

2 Likes

Little question : Do you prefer to have the choice to use a menu, with a little application ? A simple menu to just insert your file, choice the command…
I prefer to use command line (as Obsidian Shell commands change everything for me), but maybe some users prefer to use an app?

Off topic question. How to configure the terminal as yours? Ie. separated color for each folder level

I use Oh my Posh.

1 Like

Hello everyone ! I updated the readme of this topic with the lasts changes :slight_smile:

1 Like

Thank you for the great work, especially considering the new price of obsidian publish. I have a question: Is there a way to add graph view via obsidian Mkdocs?

Unfortunately not. I already looking for a way to get graph and I don’t found any idea.

There is some limitation I found :

  • First, where I put it in the css? As I use a template I need to do a big edit in the css and I hate that.
  • I need to get a responsive graph and I don’t know how I can do that.

Also, construct an image using graphviz or juggle will broke the script for mobile and it will be not very good (because not responsible and without note link)

So, for the moment, there is no graph view.

Hello !
I updated the script, and reworked all commands.

Global options :

  • --git : No commit and push to git ;
  • --mobile : Use mobile shortcuts instead of --git
  • --meta : Update frontmatter of source files
  • --keep : Don’t delete files in blog folder
  • --shell : Remove Rich printing

Commands and specific options :

  • config : (it will ignore --use configuration_name)
    • --new configuration_name : Create a specific configuration for some files
  • all : Share all vault
    • --force : Force updating (ignore the difference between the source and blog file)
    • --vault : Share all vault file, ignoring the share state.
  • file [file*] : Share only one file

Secondly, you can now create multiple configuration. For example, you can push two different vault in a different site, or the same vault on a different site. Moreover, with different sharing key, you can push different file to different blog.

  1. To create a new configuration file : obs2mk config --new configuration_name
  2. To use a configuration use : --use configuration_name For example : obs2mk --use configuration_name

Hello ! New update.
Now the script will always pull the repo before anything.
The --G options is active also on that.

In case of pull error, the script will warn you but continue to work !

Hello !
Shiny new things : The script support the new callout / Admonition Microsoft’s Syntax.
It also supports custom callout.

The script support custom admonition. For that, you first need to edit custom_attributes with adding the support, as follow in Admonition’s docs.
For example, to add a dictionnary admonition:

:root {
    --md-admonition-icon--dictionnary: url('data:image/svg+xml;charset=utf-8, <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M18 22a2 2 0 0 0 2-2V4a2 2 0 0 0-2-2h-6v7L9.5 7.5 7 9V2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12z"/></svg>')
}
.md-typeset .admonition.dictionnary,
.md-typeset details.dictionnary {
  border-color: rgb(43, 155, 70);
}
.md-typeset .dictionnary > .admonition-title,
.md-typeset .dictionnary > .summary {
  background-color: rgba(43, 155, 70, 0.1);
  border-color: rgb(43, 155, 70);
}
.md-typeset .dictionnary > .admonition-title::before,
.md-typeset .dictionnary > summary::before {
  background-color: rgb(43, 155, 70);
  -webkit-mask-image: var(--md-admonition-icon--dictionnary);
          mask-image: var(--md-admonition-icon--dictionnary);

It will give you :

The dictionnary will be recognized, and converted!

PSA for user of obs2mk, I updated the repository : now, template & script will live all together in a “big” repo, where I will store documentation, discussion and issue.

You can continue to copy the template here : GitHub - Mara-Li/mkdocs_obsidian_template: The template for mkdocs-obsidian
BUT the documentation and other will be on this repo.