A Mkdocs plugin that makes linking to other documents easy.
Project description
Fork
To install this fork :
pip install mkdocs-obsidian-links
Mkdocs - Obsidian Wikilinks
Plugin for mkdocs which enables easier linking between pages.
This plugin was written in order to provide an up-to-date and feature complete plugin for easily referencing documents with a variety of features:
- Optimized file name lookup
- Code Block Preservation
- File name linking (e.g.
[Text](file#anchor "title")) - Absolute paths (e.g.
[Text](/link/to/file.md)) - WikiLinks support (e.g.
[[Link#anchor|Link Title]]) - Reference Link support (e.g.
[foo]: bar/ "Foo Title")
Install
pip install mkdocs-obsidian-links
Edit your mkdocs configuration file to enable the plugin:
plugins:
- search
- ezlinks
NOTE
If you have no plugins entry in your config file yet, you'll likely also want to add the search plugin. MkDocs enables it by default if there is no plugins entry set, but now you have to enable it explicitly.
Configuration Options
markdown_extensions:
- attr_list
extra_css:
- css/extra.css
plugins:
- search
- ezlinks:
warn_ambiguities: {true|false}
wikilinks: {true|false}
reference_links: {true|false}
Not found
If a file is not found, the plugin will add the attr_list class ezlinks_not_found to the link. By default, obviously, the plugin won't add any style to your site. You need:
- Adding the support for
attr_listin themarkdown_extensionssection of yourmkdocs.ymlfile. - Add an
extra_cssfile to yourmkdocs.ymlfile. - Create a CSS file in your
docs_dirwith the following content:
.ezlinks_not_found {
color: red;
}
You can check the testing files to see how it can be configured.
warn_ambiguities
Determines whether to warn when an abmiguous link is encountered. An ambiguous link is one that would have more than one possible targets. For example, if you had the following document setup:
+ folder1/
+-- index.md
+ folder2/
+-- index.md
If you had any links that targeted index.md, EzLinks is not able to determine which of the instances of index.md to target, thus it is ambiguous.
Disambiguating links
By default, EzLinks will attempt to resolve the ambiguity automatically. It does this by searching for the file closest to the file that is linking (with respect to the folder hierarchy).
+ guide/
+ test.md
+ getting_started/
+ index.md
+ tutorials/
- test.md
+ getting_started/
+ index.md
+ more_advanced/
+ index.md
If you placed a link inside guide/getting_started/index.md such as [Test](test), the resulting link has ambiguity, but in the default case, the guide/test.md file is closer than the tutorials/test.md, therefore, it will select that file.
In the circumstance above, it would be possible to disambiguate which test.md by including the containing folder, e.g. guide/test.md or tutorials/test.md. Note: This also works in conjunction with extension-less targets, e.g. guide/test and tutorials/test.
This disambiguation can continue with as many parent directories are specified, for instance folder1/subfolder1/subfolder2/test.md, specifying as many path components as necessary to fully disambiguate the links.
This method of disambiguation is supported by each of the supported link formats (MD links, wiki/roamlinks). For instance, you can use [[folder1/index|Link Title]] and [[folder2/index.md]].
wikilinks
Determines whether to scan for wikilinks or not (See WikiLink Support).
NOTE
This plugin feature does not function well when the 'wikilinks' markdown extension is enabled. This plugin's functionality should replace the need for enabling said extension.
reference_links
Determins whether to scan for Reference Links or not (See Reference Links, e.g. [foo]: /bar "Foo Bar")
Features
Filename Links
Given a layout such as
- index.md
- folder/
+-- filename.md
+-- image.png
The following links will result in the following translations,
| Link | Translation |
|---|---|
[Link Text](filename) |
[Link Text](folder/filename.md) |
[Link Text](filename#Anchor) |
[Link Text](folder/filename.md#Anchor) |
[Link Text](filename.md) |
[Link Text](folder/filename.md) |
[Link Text](filename.md#Anchor) |
[Link Text](folder/filename.md#Anchor) |
 |
 |
 |
 |
 |
 |
Absolute Links
Given a layout such as
- static/
+-- image.png
- folder/
+-- document.md
- index.md
Given that we are entering the links into the folder/document.md file,
| Link | Translation |
|---|---|
 |
 |
WikiLink Support
Given a layout such as
- folder1/
+-- main.md
- folder2/
+-- page-name.md
- images/
+-- puppy.png
and these links are entered in folder1/main.md, this is how wikilinks will be translated
| Link | Translation |
|---|---|
[[Page Name]] |
[Page Name](../folder2/page-name.md) |
![[Puppy]] |
 |
[[Page Name|Link Text]] |
[Link Text](../folder2/page-name.md) |
[[Page Name#Section Heading|Link Text]] |
[Link Text](../folder2/page-name.md#section-heading) |
Attribution
This work is highly inspired from the following plugins:
I have combined some the features of these plugins, fixed several existing bugs, and am adding features in order to provide a cohesive, up-to-date, and maintained solution for the mkdocs community.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mkdocs_obsidian_links-1.0.3.tar.gz.
File metadata
- Download URL: mkdocs_obsidian_links-1.0.3.tar.gz
- Upload date:
- Size: 1.1 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.5.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
435325f3160499ab2ff2dc1f86f0fffac0f019cc3869d4be23ee881871b15989
|
|
| MD5 |
da07b3743bce9900eebe193a8f2058b5
|
|
| BLAKE2b-256 |
160b8d54dc4a49f1923471fb009f2d9051ad34ff7ed87e593b6cdc6290da0c77
|
File details
Details for the file mkdocs_obsidian_links-1.0.3-py2.py3-none-any.whl.
File metadata
- Download URL: mkdocs_obsidian_links-1.0.3-py2.py3-none-any.whl
- Upload date:
- Size: 12.6 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.5.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
31a4ac268f95ac8b8b32f36c9bba0e3c9e7f953c6f2c40daac721a3b490b772b
|
|
| MD5 |
dca0e1ce9f8ae97ccd77267942de5164
|
|
| BLAKE2b-256 |
1c51192a77110099d10e21dc79a495f0fd9ade76d0c257213a59be92b68828d1
|