Can't make cross-references work

Hey, does anyone know what I am doing wrong?

My two _index.md files only contain title, date, and draft, where draft is set to false.

But I can not link from index.md to my two posts in the math folder.
I used the following markdown:
[here]({{< relref “personal/learning-journey.md” >}})
[here]({{< relref “/personal/learning-journey.md” >}})
[here]({{< relref “personal/learning-journey” >}})
[here]({{< relref “personal/” >}})
[here]({{< relref “/personal/” >}})
[here]({{< relref “personal” >}})
and a couple more…

I either get: REF_NOT_FOUND: Ref “personal/learning-journey.md”: “C:\PersonalBlog\content\math\index.md:7:26”: page not found.
Or a 404.

Could not post the picture here, therefore I uploaded it on imgur:

Have you tried {{<ref "/persona/math/learning-journey.md" >}}? Or just {{<ref "learning-journey.md" >}}?

Can you share your repo or a minimal example that can reproduce the problem (because I use relref in almost all my posts, and they have been working well.)

Is it possible that you haven’t yet created content/personal/learning-journey.md?

@Anony

rename content/math/index.md to content/math/_index.md

1 Like

Yes, that did not change anything.

I made my repo temporarily public. You can check it out here:

Yes I made indeed a typo in the snippet I sent. I meant the file “learning-roadmap.” However, fixing the typo did not fix anything else.

Sadly, this did not help.

I don’t see a “personal” directory under content/:

But I see content/math/personal/mathematical-journey.md and content/math/personal/learning-roadmap.md. So you intersected learning-roadmap and mathematical-journey into learning-journey :slight_smile: .

So try:

  • {{< relref "learning-roadmap" >}}
  • {{< relref "mathematical-journey" >}}

Both should work.

Okay wait, maybe I should explain what I want to achieve :slight_smile:

I have the math category, which should be divided into two sections “proofs”, and some meta stuff like motivation, learning roadmap etc. which is called “personal”

My idea was that if you click on math on my website you see something like this:

“If you are interested in following my journey you can look [here].”

“If you are interested in my collections of proofs you can click [here].”

However, using {{< relref "learning-roadmap" >}} in my math/index.md does not work. I still get:
REF_NOT_FOUND: Ref "learning-roadmap": "C:\PersonalBlog\content\math\index.md:7:67": page not found

Adding .md to learning-roadmap does not work either.

This is your content structure

content/
├── blog
│   └── rust-contribution.md
├── books
│   └── readings.md
├── math
│   ├── index.md
│   ├── personal
│   │   ├── _index.md
│   │   ├── learning-roadmap.md
│   │   └── mathematical-journey.md
│   └── proofs
│       └── _index.md
└── myself
    └── about.md

  1. rename content/math/index.md to content/math/_index.md

Your current structure, math is Leaf Bundle, any md content under Leaf bundle will be treated as Page Resources, means the content will not treated as Published Page.

  1. Inside content/math/_index.md, if you want to reference to content/math/personal/learning-roadmap.md this is how to reference it.
File-Relative path reference:
{{< relref "personal/learning-roadmap.md" >}}
2 Likes

The solution that @pamubay suggested worked for me. You need to make math/ a section and not a page. index.md makes something a leaf bundle (or a single page). So you cannot nest more pages like learning-roadmap, mathematical-journey and other sections (branch bundles) like proofs under that.

You need to make it a section or branch bundle instead i.e. name the file math/_index.md (the underscore is critical here).

See Page Bundles | Hugo.


This works:

1 file changed, 2 insertions(+)
content/math/{index.md => _index.md} | 2 ++

renamed    content/math/index.md -> content/math/_index.md
rename from content/math/index.md
rename to content/math/_index.md
@@ -5,3 +5,5 @@ draft: false
 ---
 
 Follow my journey [here]({{< ref "learning-roadmap.md" >}})
+
+These work too: [here]({{< relref "learning-roadmap" >}}), [here]({{< ref "learning-roadmap" >}})
1 Like

Okay. First of all, this works. Appreciate your help!

As you can see it looks a bit “meh”.

For example, I don’t want the “Read more” or “reading time there”. However, they are specified in the config.toml for the whole site. Is it possible to make a config.toml which is only used by this particular _index.md? To be more precise by the math/_index.md?

And would it also be possible to change the layout for ONLY this particular _index.md as well?

1 Like

Yes it works. However, the text: “Follow my journey…” is not displayed. It displays only in a typical blog structure the sections. But this might be a problem with the theme itself :thinking:

Yes, that’s theme-related, you need to modify the theme.

1 Like

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