How can I connect a standalone markdown file internally in Hugo?

I created a standalone Markdown page here called cv.md (Live: https://msaharia.com/cv/)

And I am trying to connect it to my homepage about.md

This is the shortcode:

Here is my CV: [html]{{< ref "cv.md" >}} and {{% staticref "/manab_cv.pdf" %}}(PDF){{% /staticref %}}

But as you can see it on my homepage (msaharia.com), the page is not being linked correctly:

Here is my CV: [html]/cv/ and (PDF)

How can I link it?

You have a syntax error with the way you’re using ref

See: https://gohugo.io/functions/ref/#readout

Hint: Don’t forget the dot.

I tried [html]{{< ref . "cv.md" >}}

But Netlify build is showing this error:

4:51:30 PM: ERROR 2018/03/26 22:51:30 home/about.md:39: unrecognized character in shortcode action: U+002E '.'. Note: Parameters with non-alphanumeric args must be quoted
4:51:30 PM: ERROR 2018/03/26 22:51:30 error processing shortcode "_internal/shortcodes/ref.html" for page "home/about.md": template: _internal/shortcodes/ref.html:1:89: executing "_internal/shortcodes/ref.html" at <0>: invalid value; expected string

The internal Hugo shortcode has this syntax {{ ref . "about.md" }} hence the error. You need to remove the angle brackets.

Also you don’t need to type [html]

Thank you.

Now I have this:

### Here is my CV: {{ ref . "cv.md" }} and {{% staticref "/manab_cv.pdf" %}}(PDF){{% /staticref %}}

But, I still don’t see the link:

Here is my CV: {{ ref . “cv.md” }} and (PDF)

Apologies. I pointed you to the ref function. (I shouldn’t post this late at night)

Here are the Docs examples of the ref internal shortcode https://gohugo.io/content-management/shortcodes/#example-ref-and-relref-input

If you’re still having a problem, then please post a link to your Hugo project’s repository.

1 Like

Also, the .md part is optional. This should work: {{< ref "cv" >}}.

Ah, thank you so much! It works now. A quick question - anyway I can force it to open in the same tab? Right now, it’s opening another tab. Happy to open another thread here.

You forgot the parentheses:

[html]({{< ref "cv" >}})
2 Likes

Thanks. I had updated it. And links fine now.

How can I force Hugo to open the link in the same page?

My project directory: https://github.com/msaharia/msaharia.com

The easiest way is to remove hrefTargetBlank = true from your site config. There’s a bug in how Blackfriday implements that… it basically opens all absolute links in new tab. Search this forum for a recent discussion on that.

1 Like

Thank you so much. I have put hrefTargetBlank = false