Skip to content

Note aliases in frontmatter, and an autolink command that uses them #1109

Open

Description

@spirit-of-light

Summary

I want to add two items that change how notes link to each other:

  1. An aliases: list in frontmatter. A [[name]] link resolves to the note that has that alias.
  2. An autolink command. It adds a [[link]] at the first reference to each other note.

The terminal app (zn) has both items on a branch: https://github.com/spirit-of-light/tui/tree/feat/auto-link

The aliases list is a new note convention, and the desktop app, the phones and the server read the same notes. Thus, I ask for agreement here before I open a pull request for zn.

1. Aliases

A note can list other names for itself:

---
aliases: [LA, Lin Alg]
---

A block list (- LA) is also correct. The zn branch uses these rules:

  • A link resolves by path first, then by title, then by alias. A path or a title always wins over an alias.
  • An alias of a note in the trash does not resolve.
  • A link that resolves through an alias is a backlink of that note.
  • A rename of a note does not change a link that resolves through an alias. The link still names the alias.
  • The aliases are not in the JSON output of zn or of zn mcp.

Obsidian uses the same aliases: key. Thus, a vault from Obsidian works with no change.

Today the desktop app shows [[LA]] as a link to a note that does not exist. If zn writes these links and the desktop does not read aliases, the desktop shows broken links.

2. Autolink

zn autolink <path>, zn autolink --all and :autolink in the TUI add links to a note:

  • The first reference to each other note gets a link. The link keeps the original text, for example [[Theory|theories]].
  • A match is a whole word and is not case-sensitive. It also matches English singular and plural forms and the -ic/-ics pair.
  • If a later link to the same note exists, the command moves it to the first reference. A setting removes the other links to that note.
  • The command does not change frontmatter, code, math, headings, tables, task lines, comments, callout titles, URLs or HTML. It does not change links in these regions.
  • When references to two notes overlap ("Linear Algebra" and "Algebra"), the user selects one note or skips.
  • The user reviews each change before the command writes. The user can omit each change.

The command writes only plain [[...]] links. Thus, the other apps read the result with no change, except for links to aliases.

Questions

  1. Is aliases: acceptable as a shared note convention? Is the resolution order (path, title, alias) correct?
  2. Must the desktop read aliases for links and backlinks before zn can use them?
  3. Does the desktop want an autolink command too, or is it a zn feature only?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions