Struggling with hyperlinks

Repo: GitHub - chrisxfire/

I’ve been trying to use Markdown-style links with Hugo. I have a layouts/_default/_markup/render-link.html and a layouts/_default/_markup/render-image.html.

Consider the page at /notes/
On that page, the second hyperlink attempts to link to:


The Markdown for that hyperlink is…

[Dependency Injection in .NET](../../_net/dependency-injection/overview)

…which instead links to:


If I change the Markdown to…

[Dependency Injection in .NET](/notes/_net/dependency-injection/overview)

…it works. However, this is unintuitive because /notes is not the root of the repo. Below /notes is /content, so intuitively it would be /content/notes/...

Of course, links to documents not below the /notes/ level work fine.

I don’t understand Hugo Markdown render hooks well enough to fix this. Does anyone have any advice?

Without a render hook, you’re asking the browser to do this:


Which resolves to this:


Which is a 404.

Hugo publishes your site like this:

├── notes/  <--------------------------------------- UP THREE LEVELS ../../..
│   ├── _net/
│   │   ├── dependency-injection/
│   │   │   ├── overview/
│   │   │   │   └── index.html
│   │   │   └── index.html
│   │   └── index.html
│   ├── <---------------------------------- UP TWO LEVELS ../..
│   │   ├── fundamentals/  <------------------------ UP ONE LEVEL ../
│   │   │   └── services-and-dependency-injection/
│   │   │       └── index.html  <------------------- START HERE
│   │   └── index.html
│   └── index.html
└── index.html

You want to do this:


Which resolves to this:


This article might be helpful.

Wouldn’t ref or relref simplify that? Something like

[Dependency Injection in .NET]({{<ref "Dependency Injection in .NET">}})

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.