Linking pages in Hugo / markdown

I am new to HUGO Static Site Generator ( http://gohugo.io/ ). I am using a Hugo server locally available as localhost: 1313. I am trying to link pages in two different sections. My file " feature.md" needs a link to " grid_modules.md" and vice versa. The following is the directory structure for both files on the Hugo-generated site.

~/mysite/content/about/feature.md

~/mysite/content/modules/grid_modules.md

What is the best way to link both pages together? I am trying to do the following:

In feature.md:

" [grid_modules] (../modules/grid_modules)"

If I try to access this link, I get an error in " localhost:1313/about/modules/grid_modules" which, as I know, is incorrect.

What am I missing in the links? Why I do not get a " localhost:1313/modules/grid_modules" instead.

+12
source share
3 answers

This answer is based on the answer provided by bep . This answer is correct, but not very clear (since I read it many times, trying different things, before I found a solution).

As stated earlier:

The URL of the page depends on the configuration of your URL (either through https://gohugo.io/extras/permalinks/ , or directly as the URL on a separate page).

You can use tags refand relrefin your markdown to link corresponds to the correct URL.

For your example, this would look like this (depending on whether you want an absolute or relative URL):

[grid_modules] ( {{< relref "modules/grid_modules" >}})
[grid_modules] ( {{< ref "modules/grid_modules" >}})
+11
+10

. URL- [text](/url/path) /, /url/ /( / ). , "~/mysite/content/modules/grid_modules.md" "~/mysite/content/about/feature.md", "feature.md"

[grid_modules] (/modules/grid_modules)
0

Source: https://habr.com/ru/post/1612333/


All Articles