URL in .md file matter item

So I used the syntax [Visit OpenAI](https://www.openai.com) in an .md file so the {{item.url}} in the CMS would display the linked URL, but this completely breaks the CMS. So clearly this doesn’t work.

So how do I add a linked URL into a matter field in the .md file?

It’s really hard to say without seeing your project. If you’re putting it in the frontmatter, you’d do something like this:

urlTitle: "Visit OpenAI"
urlResource: "https://youtu.be/VK2B5Jmb8V0"

Then you could reference it within your site using {{item.urlTitle}} and {{item.urlResource}}.

Have you watched the CMS intro video series @ben has been recording? This will help you get up and running with the CMS.

Yes Ben’s series on setting up CMS is great but it doesn’t cover this specific issue.

Actually this is how I had it before but the url comes through as just text and not a hyperlink.

You can create URLs as data in the frontmatter, but they will not be output as hyperlinks automatically. The frontmatter is simply a data output, so this behavior is correct.

You’ll need to use the workaround of outputting the hyperlink through the template.

However, if you use [Visit OpenAI](https://www.openai.com) in the body text, the output should generate a hyperlink.

This only works for the body text, though, not for the frontmatter.

Thank you, could you help me understand how to do this?

You need to set the Link property of a Container to {{item.url}} as Plain Text.

Inside the container put a Text component with the hyperlink Title, {{item.urlTitle}}.

url and urlTitle need to be in the frontmatter like Dan said.

Thanks everyone, I will give a go later today.

FOLLOW UP:

Great thanks, all good now.