Inside an article markdown i would like to link into a section page using the ref/relref shortcodes. However when I do this, e.g.
{{< ref "articles" >}}
I’m getting No page found with path or logical name "articles".. I’m probably missing something super-simple here, but I cannot make it work for all the tea in china. So how would I create a link to a section inside markdown?
Do you happen to have relativeURLs set to true in your configuration? I ask because I wonder if it’s just easier to then write [my link to the articles](/articles) and let Hugo create the relative path for you…
That’s why I linked the markdown syntax document. What you are trying to do is easily accomplished using markdown (no need for a shortcode) for sections.
I see. However if I choose to switch the URL-scheme to ugly urls, I will have to change all “manual” markdown links created like this. This is why I wanted to use the shortcode as this transparently handles URL generation according to the site settings. It’s not much of a big deal though, so I’ll go with the markdown solution for now.
Not sure how this is related to nested sections, but this is the status:
ref/relref is (still) about linking to regular content pages (i.e. not home page, sections etc.)
you can, however, use .Site.GetPage to get to whatever you want, even regular pages, and I guess you could write a clever shortcode to handle this. This should maybe be baked into the built-in ref/relref shortcodes, but someone other than me will have to fix that.
I have the same problem to create a link to a section with relref and _index.md.
The only disgusting solution I found for that to work is:
create a link to the section like that: {{< relref "mysection/index.md" >}}
create an empty file mysection/index.md
create the mysection/_index.md file with the content of my section homepage
This way I can create a link to the section, and while going on it, it renders the content of _index.md file.
I need to work like this because I’m migrating a wiki (dokuwiki) to Hugo. So each directory is a kind of subsection of the initial wiki. But Hugo considers them as section.