PAGE SYNONYMS

The Page Synonyms extension allows you to define synonyms for pages to allow for easier referencing between common terms.
Installation
You could use the Copy Extension button below to individually install this extension. To install, just paste anywhere in your Roam graph and click "Yes, I Know What I'm Doing".
Manual Installation
If the extension doesn't work after using the copy extension button above, try installing manually using the instructions below.
First create a block with the text {{[[roam/js]]}}
on any page in your Roam DB. Then, create a single child of this block and type three backticks. A code block should appear. Copy this code and paste it into the child code block in your graph:
var existing = document.getElementById("roamjs-page-synonyms");
if (!existing) {
var extension = document.createElement("script");
extension.src = "https://roamjs.com/page-synonyms.js";
extension.id = "roamjs-page-synonyms";
extension.async = true;
extension.type = "text/javascript";
document.getElementsByTagName("head")[0].appendChild(extension);
}
Finally, click "Yes, I Know What I'm Doing".
Usage
This extension adds a new option to block context menus that says "Alias Page Synonyms". Right click a block and click on the option to replace all text in the block with a reference to its defined alias. To define aliases, go to the page and add an Aliases
attribute. All values should be comma delimited.
For example, to have Tasks
and task
alias back to Task
, create an Aliases
attribute on the Task
page. The page should have a block that displays Aliases:: Tasks, task
.
The extension also works for selecting multiple blocks. When you highlight and right click multiple selected blocks, the "Alias Page Synonyms" will appear and perform the same operation as described above.
Note that the extension does a simple search and replace. That means if aliases are nested in other words or already have links, it will still replace the instance with a new link.
PS! By default, the extensions replace synonyms using the [synonym](((page-uid)))
format. To use tags instead, add a block that says "Use Tags" in the [[roam/js/page-synonyms]]
page. Roam may crash for some using the [synonym](((page-uid)))
format but will work through tags.
Developers
The main method to convert a block's text to synonyms is exposed through a public API. Developers could convert alias synonyms for any block by calling:
window.roamjs.extension.pageSynonyms.aliasBlock({
blockUid,
});
Demo
Contributors
This extension is brought to you by RoamJS! If you are facing any issues reach out to support@roamjs.com or click on the chat button on the bottom right.
If you get value from using this extension, consider sponsoring RoamJS by clicking on the button below!