Getting Obsidian to work with Nextcloud
If you want to skip the noise and get to the signal of my clumsy - but working - setup, subscribe and read the detailed Steps. Disclaimer: the setup is convoluted, involved, and not extremely elegant so reader beware.
Why Nextcloud?
I use Nextcloud running in a Docker container on Unraid in my basement and, for the most part, it's been extremely reliable for years. I did this as part of my de-Googling process, which never ends btw. Nextcloud is a great solution for managing my 1,000's of files and contacts, my photos, calendar, notes, and tasks and it makes those accessible from all of my devices. Right now my data is in my server (old PC with some 4 TB hard drives) which is in my house so I know exactly where the bits are.
Why not just use Nextcloud Notes?
Good question. Nextcloud Notes is integrated tightly into Nextcloud solution so that is a big bonus but I found it pretty basic so I started looking at alternatives. See: "Why this rabbit hole?"
Why Obsidian?
Obsidian is quite new to me and so far is pretty incredible. It's local-file focused and designed to be a tool for managing your own notes without the need of a Cloud. Obsidian does not support the WebDAV standard which is what Nextcloud uses for remote access to files.
Why not Obsidian Sync?
Obsidian Sync is a paid service which costs $10/mo or $96/yr and it synchronizes your vaults across devices with end-to-end encryption. In reality, that's not a lot of money to keep your second brain / Personal Knowledge Management (PKM) up to date across your devices.
I really want the data to be mine, all mine and not traverse anyone else's servers, even Obsidian's. I trust myself and I don't want my data to leave my home. In reality, I may switch to their Sync once I trust them or if my poor person's sync solution annoys me too much.
Why not use an Android WebDAV sync app?
I tried a few of the Android folder / sync apps that support WebDAV and none worked well with Nextcloud. One I couldn't even connect and the other didn't allow me to sync a specific folder nor actually sync individual files. I could likely debug and continue but I was lazy.
Before you start
This solution does NOT work with the Nextcloud Notes so your Obsidian notes will be completely separate. The Obsidian notes will still be accessible in Nextcloud Files – but not in Nextcloud Notes app itself.
The steps below assume the following:
- You have a Nextcloud Server either a Nextcloud Server that you host OR one you subscribe to from a Nextcloud provider
- You have an Android phone
- Your Smartphone can access the Nextcloud Server: I know, it's obvious but had to say it!
- You made sure to back up any and all data, preferably in multiple places
- You have a lot of time to spare and are not looking for an elegant and simple solution :)
Steps
The next sections provide details on how I set this up. I can guarantee there's a better way (e.g. pay for Obsidian Sync!) but it was fun getting this working.
Install Android apps
If not already done:
- Install Nextcloud on Android and login to the server
- Install Obsidian on Android
- Install MacroDroid on Android - this is optional, it's a tool that can automate tasks, it can simulate user interactions and act on certain triggers
In Nextcloud
Either in the Nextcloud app, your server, or the cloud service:
- Directly under
Files
create a folder namedObsidian
- this is where ALL of your Obsidian notes (.md files), attachments will go, including the hidden.Obsidian
folder that contains your vault - Use the ":" on the right of the
Obsidian
folder and choose "add to Favorites" so it's at the top of theFiles
list
3. Inside Obsidian
folder, create a sub-folder Attachments
- this is where you'll put images, etc.
4. Inside Obsidian
folder, create a sub-folder Unfiled
- this is where your new notes will go
In Obsidian
In the Obsidian app on your Android phone create a vault from the Nextcloud > Obsidian
folder. I use the same approach on my Obsidian on Windows 10 and works like a charm.
- Click the vault icon and select
Open folder as vault
2. Navigate to the location in Android where Nextcloud stores it's files. For me it's Internal storage > Android > media > com.nextcloud.client > nextcloud > [user account]
you should see something like the below screenshot
3. Open the Obsidian
folder and then click USE THIS FOLDER
This part may be optional
4. In Obsian's Settings > Files & Links
, choose to store attachments in Attachments
Using the solution
Nextcloud is not really a synchronization tool, it's more of an upload and download. It only knows about files that you add via Nextcloud app or Web. If you add files outside of the app, Nextcloud won't scan or look for them. If they did, it would save a lot of the manual steps.
ALWAYS USE NEXTCLOUD to create, upload (and download), and move files either manually in the Nextcloud app or via the macro described at the end.
Creating an Obsidian note
In Nextcloud I create my new notes under the Unfiled
folder making sure to use / append the ".md"
file extension so Obsidian can open them.
Since Nextcloud uses virtual files, you actually have to also download the file so Obsidian can see it (I know, this is silly)
Editing an Obsidian note
Any edited notes in Obsidian are not auto-uploaded to Nextcloud so you need to manually sync the file. At the bottom of this page, I show how you can automate this with MacroDroid.
Moving an Obsidian note
I always use Nextcloud to move the note files, not Obsidian!
Adding an attachment
I add the file via Nextcloud, then embed in the note in Obsidian. For example, screenshots I take or photos, I use "Share" to upload them to my Nextcloud Obsidian > Attachments
folder so they can be referenced in an Obsidian note.
These get synchronized back to Nextcloud server and are available in the Windows Obsidian client in about 30 seconds but not visible in the Obsidian app until you do force the download like was shown above for notes.
What works
- If you add a
".md"
note file via Nextcloud Web or another device, the note shows up in Obsidian Vault after it is downloaded via Nextcloud app
What doesn't work
- If you create files using
+
in Nextcloud, you still have to Download new files via Nextcloud app so that Obsidian can see them (I know, it sounds odd) - This is the hardest part: if you add a file or folder via Obsidian app it will not show up in Nextcloud. I opened a bug report "Does not scan new files added to filesystem" but they see it as an enhancement and closed it so it won't get done
Automating
This is the most painful but rewarding section, reader beware!
The MacDroid app is not mandatory, it can be used to automate some of the manual steps in Nextcloud. It took a few hours to get used to MacroDroid but once setup, it works very well and reliably. I ended up buying the app since the full screen ads were way too annoying.
In MacroDroid
Using MacroDroid I created two macros:
Synchronize Obsidian folder via Nextcloud
Here's what the macro looks like. You won't be able to just copy this but it gives you an idea of the steps
Create a new note file via Nextcloud
Here's the macro working
Here's what the create Nextcloud file looks like in MacroDroid
Create a handy tray
The "MacroDroid Drawer" feature is useful to make the macros very easily accessible with a single swipe from the right on your Android phone.
You can add items to the "drawer" using "+" and re-order them.
end.