Ref relref from data/frontmatter/params to content

I barely use the markdown. I like to keep most data driven.

So I wondered how I can create links inside of a “description” variable, that I’m going to just markdownify or something else.

myvar: This is a text ment to be as markdown. But [this]( {{< ref "" >}})

Am I’m missing something, or is it just not possible?

You can’t use shortcodes in your front matter. But you don’t need to do that, as your template/partials can find the url for you:

    text: lorem ipsum...
    link: post/

In your template:

{{ with }} 
<a href="{{ .link }}">{{ .text }}</a>
{{ end }}

Or something along those lines. You’ll have to find an alternate solution that suits you best. Your content files are here to handle content, so you can only do so much with them. I.e. you can’t nest shortcodes in the content either.

Note ref and relref are available in templates:

{{ relref . "" }}

You just need to pass a page as the second argument (the . here).

Good luck!

Thank you very much. I have that already. It still is not the solution to my problem. My Problem is: I don’t want to use MD. Just data, or the front matter. All my rendering is done in the template. Still there is a need to add basic format like links and emphasis in the data, because I want to have it convenient. I think the data driven approach is far supperior to the pure markdown support, as I don’t have strucutured access to MD and can’t change the rendering for this part.

I need some solution to link text in the data presentation to a site. So therefore I have to be able to execute code from the data portion. And from my understanding mardownify would be the best bett.

Any further ideas on that topic?

Either you can make relative references and that’s ok:

myvar: Markdownify will only process [links in markdown](subfolder), not {{< shortcodes >}}

That will link to the markdown file ./subfolder/
Otherwise you’ll have to use the templating language to process the variable.

I’d still recommend that you try out different approaches. Data-driven content isn’t superior or anything. There’s a place for data, and another one for markdown. Hugo is very flexible in that it allows you to load content from multiple markdown files on a single page, hence you can create one content piece per block if you so desire. Shortcodes are here to bring some logic and reusable pieces to your content files. It will save you some headaches, because if you go only with data, you’ll have to use the templating language a lot, and you’ll soon end up with bloated template files. I personally try to stay away from it as it adds complexity to the stack.