Hugo Cosmos supports WikiLinks feature so that you can realize internal link in your knowledge base.

Configuration

To use wikilink in Hugo Cosmos, you should enable these options:

1
2
3
4
5
  # (Optional, default false) enable wikilink feature.
  [params.wikilink]
    enableWikilink = true
    enableBacklinks = true
    enableLinkPreview = false

Usage

Specifically, any word surrounded by doubled square brackets is converted to a link. For example, Markdown Syntax is an article illustrate how to write markdown document and we refer the article here.

1
2
# wikilink format
[[posts/absolute-path | Absolute Path]]

You can see that the wikilink is translated to markdown links. At the same time, you can see backlinks in the Markdown Syntax article.

Tip

This feature is provided for better cooperation between Hugo Cosmos and Obsidian.

Currently, wikilinks and backlinks is implemented using simple regex matching. There are are some known issues.

  1. wikilink in inline code or code block would also be replaced by regex, which may cause ref error
  2. graph view has not been implemented
  3. block reference has not been implemented

Cross directory reference

Features

Tip
  1. Your wikilink reference should not start with /.
  2. When you refer another notes from a different directory, you should add the directory name in your wikilink reference.

For example, if doc A is under the directory content/docs/doc-a.md, doc A want to refer doc B content/posts/doc-b.md

You should write the wikilink below in the doc A:

1
[[posts/doc-b]]

Same directory reference

You can also check other features like Code Blocks

Tip
  1. When you refer another note from the same directory, the directory name don’t need to be added.

For example, if doc A is under the directory content/docs/doc-a.md, doc A want to refer doc C content/docs/doc-c.md

You can write the wikilink below in the doc A:

1
[[docs/doc-b]]

or

1
[[doc-b]]

Pipe Symbol

Hugo Cosmos would use the page title as the wikilink display text by default. For example:

Icon Sets

You can also use the pipe symbol | to override the default text. For example:

New Display Text for Icon Sets

Block Reference

Hugo cosmos also supports block reference. For example:

1
[[icon-sets#anchor]]

Icon Sets > Custom icon sets