Ways to write markdown links without language prefix?

You included the markdown render hook that I provided, so I assumed you wanted to use it!

When I mentioned relLangURL, I was actually asking if this can be done with a render hook, without pointing to page path. Because I thought it was the only way to solve this, while maintiaining the link structure, but omitting the language prefix. While I see the importance of using file path, I (and my team) are very hesitant to use it for the reasons I mentioned.

That’s the only way to ensure true portability. You can a subdir to your baseURL, add url to front matter, add slug to front matter, setup permalinks in your site configuration, switch to uglyURLs, and it will just work.

To be precise, I recommended using .Page.GetPage.

1 Like
(.Page.GetPage .Destination).RelPermalink | safeURL 

That came close to doing what I want. But it turns all other links into the same link of of the parent page with the markdown links.

But to avoid any issues now and in future, we’ve decided to continue hardcoding the language prefix for now and let the editors (me being one of them) to check if the URLs are correct.

One more effort to make your life easier, long term.

This works. Eliminate leading and trailing slashes.

diff --git a/content/posts/test/ipsum/index.fr.md b/content/posts/test/ipsum/index.fr.md
index 34fea14..a212d3a 100644
--- a/content/posts/test/ipsum/index.fr.md
+++ b/content/posts/test/ipsum/index.fr.md
@@ -8,6 +8,6 @@ Lorem markdownum crebri. Sunt risere diu blandis neque; more nobis *doctas*!
 Corpore creavit licent nec quaecumque fama habebam liquitur fumo terrore bella
 est extemplo gramen pedibus Lenaee Credulitas magis revolet. Pestiferos mutat,
 aut properas, sic te **relictus** regno **dignoque Cromyona Victoria** erat est
-olivis feliciter. A iners [clamato capillos](/lorem-fr/),
+olivis feliciter. A iners [clamato capillos](lorem),
 lunae aliud ditia adveniet Circen, deusque at animal et obstitit Colchis ignavo
-media.
\ No newline at end of file
+media.
diff --git a/content/posts/test/ipsum/index.md b/content/posts/test/ipsum/index.md
index db8ee26..c685d46 100644
--- a/content/posts/test/ipsum/index.md
+++ b/content/posts/test/ipsum/index.md
@@ -3,4 +3,4 @@ title: Ipsum
 url: "ipsum"
 date: 04 Dec 2022
 ---
-Cratem responsa evolat moresque Iunonis tabuerant scylla? Deducitur oneratos pretioque [habendum nube residant](/lorem/); in nil accedat sacra, meque plebe et suos! Insignis iusserat magnanimo visa ad illos colubris nihil puppim? Me ab et levis captavit, perosus trunca!
+Cratem responsa evolat moresque Iunonis tabuerant scylla? Deducitur oneratos pretioque [habendum nube residant](lorem); in nil accedat sacra, meque plebe et suos! Insignis iusserat magnanimo visa ad illos colubris nihil puppim? Me ab et levis captavit, perosus trunca!
diff --git a/content/posts/test/lorem/index.fr.md b/content/posts/test/lorem/index.fr.md
index 973c58e..510317a 100644
--- a/content/posts/test/lorem/index.fr.md
+++ b/content/posts/test/lorem/index.fr.md
@@ -8,6 +8,6 @@ Lorem markdownum crebri. Sunt risere diu blandis neque; more nobis *doctas*!
 Corpore creavit licent nec quaecumque fama habebam liquitur fumo terrore bella
 est extemplo gramen pedibus Lenaee Credulitas magis revolet. Pestiferos mutat,
 aut properas, sic te **relictus** regno **dignoque Cromyona Victoria** erat est
-olivis feliciter. A iners [clamato capillos](/ipsum-fr/),
+olivis feliciter. A iners [clamato capillos](ipsum),
 lunae aliud ditia adveniet Circen, deusque at animal et obstitit Colchis ignavo
-media.
\ No newline at end of file
+media.
diff --git a/content/posts/test/lorem/index.md b/content/posts/test/lorem/index.md
index 83904ea..6a006c3 100644
--- a/content/posts/test/lorem/index.md
+++ b/content/posts/test/lorem/index.md
@@ -3,4 +3,4 @@ title: Lorem
 url: "lorem"
 date: 05 Dec 2022
 ---
-Cratem responsa evolat moresque Iunonis tabuerant scylla? Deducitur oneratos pretioque [habendum nube residant](/ipsum/); in nil accedat sacra, meque plebe et suos! Insignis iusserat magnanimo visa ad illos colubris nihil puppim? Me ab et levis captavit, perosus trunca!
+Cratem responsa evolat moresque Iunonis tabuerant scylla? Deducitur oneratos pretioque [habendum nube residant](ipsum); in nil accedat sacra, meque plebe et suos! Insignis iusserat magnanimo visa ad illos colubris nihil puppim? Me ab et levis captavit, perosus trunca!

I did that before, but it prepends the current post’s URL before the slug/url.

Overall, I am not aware how others use internal links after they have moved to Hugo and adapt multilingual…Hugo is the first one I have seen where file path is used to point to permalink, rather than the URL itself being added as the link

For anyone coming across this topic in the future:

git clone --single-branch -b hugo-forum-topic-41939 https://github.com/jmooring/hugo-testing hugo-forum-topic-41939
cd hugo-forum-topic-41939
hugo server
2 Likes

Thinking about this in-depth, should it be documented? That is, internal markdown links in Hugo should point to file path? Especially for translated files and/or new projects? (We are so deep in Hugo, so there’s not going back now).

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