HUGO

Possible to use regular markdown links to other .md files, rather than shortcodes?

Is it possible to use regular markdown links to other .md files in Hugo, or must one always use a shortcode?

To link to images and non-MD files, regular markdown links work, especially now with bundles as a feature. ex. ![image](/path/to/image)

But my understanding is that for other .md files, you need to use a shortcode:
[another article]({{< ref "path/to/file.md" >}}).

This shortcode is a little cumbersome and also not entirely futureproof. If stop using Hugo, these don’t render to regular HTML links as regular .md links do.

Is there are hack to get around this? Or am I misunderstanding something?

Why would you want to link to the .md files and not to their permalink?

Also Hugo 0.32+ supports symbolic links (if that’s what you mean).

It’s more about economy of writing the links and also so that they still work on my local machine. If I put the file path in the normal way, when I render the markdown, the links work locally. It’s more natural for me to just type in the .md file name. I suppose I could just make a keyboard snippet for shortcodes. I’ll read up on symbolic links in 0.32

As far as I can see, no, there is no way around it. Template code goes in templates, and the workaround to use that in markdown files is to use shortcodes.

I think that happens no matter what SSG you’re using / converting to.

In my opinion, use the permalink instead because, then at least you have a chance of converting directly, if you switch away from Hugo (but, why would you want to?! :slight_smile: )

The nice thing about having normal .md links in the files for me is that you can use the same markdown file on github and on hugo. In general, I’d like to write a bunch of ‘normal’ md files, then have hugo build them into my pages based on my theme and config, not pollute my markdown files with Hugo-only shortcodes (which look bad and don’t work when you try to click them on Github, for instance)

Is there a way to convert all of the links like

[Folding Example](/examples/folding.md)

so that they come out in the built site as

<a href="/examples/folding-example">Folding Example</a>

instead of

<a href="/examples/folding-example.md">Folding Example</a>

which 404s?

Ideally without adding a shortcode to the markdown file, since that will break the link when viewing the same page on Github.

I think I managed to get this working through a config change:

[permalinks]
posts = "/:sections/:slug.md"

This seems to work pretty well for my purposes!

Did you get this to work? I have the same requirement, and am surprised it’s so hard to accomplish with Hugo, whereas other SSGs do it by default.