Publish vault with Obsidian Github Publisher and mkdocs

In a beautiful day, I have interest to publish a trading journal using mkdocs. In my setup, I use the GitHub Publisher plugin to send the notes written in Obsidian, into a GitHub repository, then deploy on Netlify and Cloudflare Pages.

Steps to install and configure

with Netlify

  1. Create a new repository from this template 1. This new repo will be called trade-bt-mkdocs
  2. Connect my Netlify account to the repo trade-bt-mkdocs and deploy via Netlify
    • Retrieve the URL of deployed site in Domain settings within Netlify
    • Read the tutorial in details to learn how to deploy
  3. Since I deploy via Netlify, I have to modify the requirements.txt as discussed at here
    • Change: obsidiantools==0.10.0 -> obsidiantools==0.8.1. Reason: Netlify only support python 3.8
  4. Configure in "GitHub Publisher" plugin settings
    • Create a personal access token (classic) then paste it into the "GitHub Token" field in "GitHub Configuration" tab. Also change "Repo Name", "Github Username"
    • I did not choose the new fine-grained personal access token as instructed 2, because it requires an expiry date within 1 year, and I don't want to set an expiry date for this token
    • In "Plugin Settings" tab,
      • change "Share Key" to dg-publish. Reason: I want to use the same publishing keyword with Obsidian Digital Garden
      • change "Excluded Folder" to 99_template. Reason: I don't need to publish any notes within this folder
    • In "Upload Configuration" tab,
      • set "Folder behavior" to Obsidian Path. I want to replicate the folder structure of Obsidian vault to the published site 3
      • set "Default folder" to docs
  5. Close and reopen Obsidian to assure that the changes are executed. Because I also encounter the same error as this user's issue
  6. Configure the file mkdocs.yml in the repo trade-bt-mkdocs
    • change the site_url into the valid Netlify link from previous step
    • add the Navigation footer to include links to the previous and next page of the current page
    • change the colors
    • change the fonts
    • change the logo and icons
    • (optional) set up the navigation tree. I didn't do this step. Because i don't want to change manually the items in the navigation tree whenever I change the file structure
    • add a git repository
  7. Enable the Comments section for specific page only
    • Update 20230114, according this reply of plugin developer, she has recently updated the template. Please follow her updated tutorial to learn how to enable the Comments section for specific page only
    • Read here to understand why the key template: custom.html works
    • In this section, the author explain how to extend the mkdocs-material using the custom_dir setting, what's the meaning of folder overrides, partials
    • (obsolete, update 20230114) in GitHub repo, path trade-bt-mkdocs/overrides/, duplicate the main.html as page_comments.html. After that, in the note (page) where I want to enable the comments, I will add the key template: page_comments.html in its frontmatter. 4
  8. (Optional) Disable the workflow Building Mkdocs Page in GitHub Actions 5, since I deploy solely via Netlify. This only helps the repo status clean. It does not affect on the success of build process.
  9. Create a custom front page

with Cloudflare Pages

  1. Create a new repository from this template. This new repo will be called trade-bt-mkdocs
  2. Connect my Cloudflare account to the repo trade-bt-mkdocs and deploy via Cloudflare Pages
    • Retrieve the URL of deployed site in Domain settings within Cloudflare
  3. Since Cloudflare Pages support only up to python 3.7 1, i need to modify the file trade-bt-mkdocs/runtime.txt from 3.8 to 3.7. And also modify the requirements.txt as in configuration step with Netlify
  4. From step 4 through 9, they are similar to the Netlify part.

How to write notes and then publish?

  1. Write note in Obsidian
  2. In the note's frontmatter, add the key dg-publish: true. This action mark that this specific will be sent to the trade-bt-mkdocs repo and then deploy via Netlify
  3. CTRL + P to open Command Palette in Obsidian, search for
    • command Github Publisher: Share active file to send only this active note
    • or command Github Publisher: Upload all shared note to send all the notes with the key dg-publish: true

Notes

Working folder of a mkdocs repository

Each Markdown file inside the folder docs will be rendered as a page of the site. The index page is located at docs\index.md. Sub-folders are used as the path to a group of related posts.

If a post is named other than index.md, the filename will be used as the directory path of the generated page. Here is how MkDocs generates URLs for Markdown posts:

  • folder docs becomes the root of the site www.site.com/
  • file docs\blog\post.md becomes the link www.site.com/blog/post/
  • file docs\blog\post\index.md also becomes the link www.site.com/blog/post/

Tags

  1. cat.tut

Footnotes

  1. https://developers.cloudflare.com/pages/framework-guides/deploy-an-mkdocs-site/˄

  2. https://dg-docs.ole.dev/advanced/fine-grained-access-token/˄

  3. https://obsidian-publisher.netlify.app/obsidian/#upload-configuration˄

  4. https://github.com/ObsidianPublisher/obsidian-github-publisher/discussions/70#discussioncomment-4656676˄

  5. https://docs.github.com/en/actions/managing-workflow-runs/disabling-and-enabling-a-workflow˄


Backlinks