MojoPad

Linked Files and Folders

A page can be a file on your disk, and stay one. Three things people do with this. A researcher keeps a folder of Markdown notes another tool writes, and wants them readable and linkable here without copying them. A writer keeps chapters as files so a different editor can open them. Somebody has a folder they have curated for years and wants MojoPad to follow it — new files becoming pages, edits arriving, without ever holding a second copy that drifts.

This is not importing. An imported file is copied in and the original stops mattering; a linked page and the file on disk are the same thing seen twice, and editing either changes both. If you want the copy instead, see Importing.

Sometimes a note shouldn't move in at all. Three cases where that's true:

  • The note already lives in a folder another app indexes. Your document manager watches a folder; a markdown file in it is part of your searchable library, and you'd lose that by copying it into a wiki.
  • Someone else edits it too. A README in a project folder, a shared file in a synced folder — it has to stay where the other person (or the other machine) expects it.
  • You want it in two places at once. Written on the iPad in a plain markdown editor, thought about in MojoPad.

For those, choose File ▸ New Page from a File… and pick the file. You get a normal MojoPad page — it links, it's found by search, it shows up in the graph, it takes backlinks — except its words live in that file. Type here and the file changes. Change the file in any other app and the page catches up, usually before you've looked back at it. Nothing is copied and nothing is converted.

The page carries a small ⇄ filename mark under its title, so you always know which pages reach outside the document. Click it to show the file in the Finder.

Follow a whole folder

One file at a time is right for a handful of notes. When the thing you want to work with is a folder — an indexed folder, a vault, a repo's notes directory — choose File ▸ Link a Folder… instead. Every text file in it becomes a page, the folders inside it become folders in your sidebar, and files added to it later turn up as pages on their own, whether they were added while you were working or while MojoPad was closed.

That last part is what makes it feel like one library rather than two: clip something into the folder from another app, and a minute later it's a page here, searchable and ready to link.

Files MojoPad can't treat as notes — images, PDFs, anything that isn't text — are left alone rather than turned into pages, and hidden folders are skipped.

A folder is followed all the way down. Sub-folders, and sub-folders inside those, become folders in your sidebar in the same shape they have on disk — so a notes directory of a few thousand files across dozens of folders comes in whole, not just the files sitting at the top level. There is a ceiling, in the thousands, and if your folder is past it MojoPad tells you the real number it found, follows as many as it can, and leaves the rest alone. Two things to know if you meet it:

  • Follow the part you want instead. If the notes you actually work in sit in one sub-folder, follow that sub-folder — everything in it comes in, and nothing is left to chance.
  • You can follow more than one folder. A wiki isn't limited to a single arrangement, so two or three folders followed separately will between them cover more than one enormous folder can.

To see exactly where you stand, Help ▸ Save Diagnostic Report counts each followed folder the same way MojoPad itself does: how many files in it can be followed, and how many of them have pages. When those two numbers match, you have all of it.

File ▸ Files on This Mac ▸ Stop Following a Folder… ends the arrangement — as does Stop Following in the right-click menu of the folder itself, which is the same thing from wherever you happen to be looking. Files you add to that folder stop turning up here, and MojoPad asks what should happen to the pages that came from it:

  • Keep the pages. They stay, each still linked to its own file. Use this when you want to go on writing here but not to hear about anything new.
  • Remove the pages. They go to Recently Deleted, where you can get them back for 30 days, and the folder leaves your sidebar. Use this when the project is over.
  • Keep just the folders. The pages go, exactly as above, but the shape of the folder tree stays behind — empty, and yours. Use this when you liked the way the folder was organised and want to go on filing your own writing that way. It is the same removal with the tidying-up left out: an empty tree is debris when nobody asked for it and a skeleton when they did.

The files on your Mac are left alone whichever you choose — stopping following never touches a file.

Follow the folder again later and the pages you removed come back — the same pages, with their links and their place in the tree — rather than arriving a second time alongside their own ghosts. And if the folder has simply gone missing from your sidebar, choosing Link a Folder… and picking it again puts it back where it was, with everything that came from it inside.

When the folder should lead

You keep a literature folder, and things in it move and go. You throw out a paper you have finished with, and a week later notice its page still sitting in your wiki — so now you delete it here too, and you are doing everything twice. That is the case this is for.

Right-click a followed folder in the sidebar and choose This Folder Leads…. It is off until you turn it on, and you turn it on one folder at a time — which side leads is a property of the arrangement rather than of the app, and a journal you only ever add to is nothing like a literature folder where things come and go.

With it on, the two match in both directions:

  • Move a file to the Trash in the Finder and its page here goes to Recently Deleted. MojoPad tells you when it happens and offers you it back in one click.
  • Delete a page here and its file goes to the Trash in the Finder — one page, or a whole selection of them from the Pages palette.
  • Take a file back out of the Trash and its page comes back too — the same page, with its links and its place in the tree.
  • Restore a page from File ▸ Recently Deleted and it stays restored. If its file went to the Trash with it, the page comes back as a page of its own — words, links and all, no longer tied to a file that is not there. It has to: a page pointing at a missing file is exactly what this arrangement takes away, so restoring it any other way would mean the next look at the folder undid your restore. If the file is still sitting in the folder, the page keeps its link and goes back where it was.

Nothing is destroyed in either direction. The Trash is the Trash until you empty it, and Recently Deleted holds a page for 30 days. A misdrag costs you a moment, not a note.

Being unable to see a folder is never the same as it being empty. This is the part worth trusting, because it is the part that would matter. A followed folder can live on an external disk, a network share, or a cloud folder halfway through syncing, and any of those can be unreachable for reasons that have nothing to do with anybody deleting anything. MojoPad will only take a page when the file's own folder is right there, readable, and simply without it. Unplug the disk and nothing happens. Lose the network and nothing happens. Leave a sync half-finished and nothing happens. It waits until it can actually see, and it checks each folder separately — one share going quiet doesn't stop it noticing a deletion in a folder on your desk.

Turning it on asks about what is already here. If you have followed a folder for a year, some of its files went long ago and their pages stayed. MojoPad counts those, tells you how many, and lets you either bring them into line now or leave them alone and have the new arrangement apply only from here on.

To turn it off again, right-click the folder and choose This Folder Leads a second time — the tick disappears and deleting on either side goes back to leaving the other alone. And if you ever wonder whether a folder is leading, Help ▸ Save Diagnostic Report says so for each one — except on a wiki with a password, where the report cannot read the list from disk and says that instead.

Set it up in two minutes

Say you keep your reading notes in ~/Notes, and another app already watches that folder.

  1. Choose File ▸ Files on This Mac ▸ Link a Folder… and pick ~/Notes.
  2. MojoPad counts what it found and asks before doing anything. Say Follow.
  3. A folder called Notes appears in your sidebar with a page for every text file, arranged the way the folder is arranged.
  4. Open one and type. Wait a moment, then look at the file in the other app — your sentence is there.
  5. Now edit that file in the other app and save. Come back to MojoPad without touching anything: the page has already caught up.

That round trip is the whole feature. Everything else is what happens when it gets complicated.

Working with a document manager's indexed folder

This is the arrangement most people are after: the document manager holds the documents, MojoPad holds the thinking, and one folder is common ground. Two things are worth knowing.

MojoPad writes into the file, it doesn't replace it. That matters more than it sounds. Apps that save by writing a new file and swapping it out break any link pointing at the old one — so if you keep item links to that document (DEVONthink's Make Custom URL Link, and the equivalent elsewhere), they'd stop working every time you edited. MojoPad edits the file in place, so the item stays the same item and your links keep resolving.

A file created after the folder was indexed needs one nudge. A document manager notices changes to files it already knows about within seconds — that's the direction that matters, and it just works. But a brand-new file appearing in the folder may not show up until it rescans. In DEVONthink: select the indexed group and choose File ▸ Update Indexed Items. This is the other app's behaviour, not MojoPad's, and it catches everyone once — including us, while building this.

The smooth path, then: make new pages from files the other app already knows about, and when you do add a file from outside, run its update once.

One file, or a whole folder?

One file when a particular note needs to live somewhere specific — a README beside its code, a document someone else edits, a file you also open on a phone. A folder when you want two apps to share a working library, and you want new files to keep arriving without asking.

You can do both in one wiki, and a folder you follow can sit alongside hundreds of ordinary pages. Linked pages are ordinary pages in every other respect: they link, they take backlinks, they're found by search, they show up in the graph, and they can be tagged and given properties like anything else. Those extras live in the document, not in the file — so tagging a linked page doesn't scribble on someone else's file.

When something looks wrong

  • The page says “not connected.” This document hasn't been allowed to use that file on this Mac. That's normal for a wiki that came from somewhere else, or one restored onto a new machine — MojoPad asks once when the document opens, and you can say yes then. Meanwhile the page shows the copy kept inside the document, so nothing is lost.
  • Edits aren't reaching the file. Check the page still shows its mark. If the file was moved or renamed outside MojoPad, the page keeps its words but has nothing to write to — make a new linked page from the file in its new home.
  • A new file in a followed folder hasn't appeared. Give it a moment; if it still hasn't, check it's a text file and that it isn't inside a hidden folder.
  • Some of the folder came in and some didn't. Save a diagnostic report and look at the Linked external files section: it says how many files that folder has and how many have pages. If the folder is past what MojoPad takes from one folder, the report says so outright — follow the sub-folder you want instead, as above. Choosing Link a Folder… on a folder already being followed is safe, and picks up anything that was missed.
  • You want the whole picture. Help ▸ Save Diagnostic Report has a Linked external files section listing every linked page, every folder being followed, which folders are approved on this Mac, and any file that has gone missing or drifted out of step.

Send a page you already have out to a file

The other direction. A page that has been in your wiki for years can be given a home on disk: open it and choose File ▸ Files on This Mac ▸ Move This Page to a File…, then say where it should live. Its words go into that file, and from then on the page and the file are the same thing — edit either.

What moves is the writing. Its name, tags, properties, aliases and backlinks stay here, in the wiki, exactly as they were; the file gets the words alone. A rich-text page becomes Markdown on the way out, so anything Markdown can't express is simplified — MojoPad says so before it does anything, and you can stop there.

Some pages can't go: a storyboard would lose its shape as a flat file (use Send Storyboard To instead), an imported file or a canvas isn't writing, and a protected page won't be written out in the clear.

When you both change it at once

If you edit the page while another app edits the file, MojoPad stops rather than guess: a bar appears offering Use the file's or Keep mine. Neither version is thrown away before you choose — pick Keep mine and your text goes out to the file, pick Use the file's and the page takes what's on disk.

What to expect

  • Renaming the page doesn't rename the file, and deleting the page doesn't delete the file — the page moves to the Trash and the file stays exactly where it is.
  • Only text files can be linked — the same kinds MojoPad imports: Markdown (.md, .markdown), plain text (.txt), Org-mode (.org), reStructuredText (.rst), AsciiDoc (.adoc), LaTeX (.tex), TaskPaper and log files. A markdown file becomes a Markdown page; every other kind becomes a plain text page, and that is the point — what MojoPad writes back is exactly the characters that were there, so an Org file stays an Org file rather than being quietly rewritten as something else.
  • Deleting the file doesn't cost you the words. MojoPad keeps a copy inside the document, so the page still opens, still searches and still shows up in the graph when the file is gone — on a disconnected drive, say. Put the file back and the page reconnects to it.
  • A document with a password can't have linked pages. The whole point of that password is that your words aren't sitting in the clear, and a file outside the document would be.
  • Open a document that someone else made and MojoPad asks before touching any file it points at, naming the folders. Say no and those pages still open — from the copies stored inside the document — and the page says not connected under its title so you can tell at a glance. Nothing on disk is read or written until you allow it.
  • macOS may ask too. The first time MojoPad reaches a file in your Desktop, Documents or Downloads folder, macOS puts up its own permission alert. That's the system asking, not MojoPad, and it only happens once per folder.
  • If the page and the file both change while they're apart — you wrote on another Mac, and the file changed on this one — MojoPad won't pick a winner. You get the same Use the file's / Keep mine choice, with both versions intact.