How do you remove Front Matter from an external link using Hugo framework?

35 views Asked by At

I am building a webpage for my organization that requires external links. It seems as though the current hugo functionality is it will not allow any external links to other websites. Anytime I add a link to index.html, once it is rendered, front matter is always included in the link.

I am using the doks theme.

In my config.toml file I added the code below..

[params]
  externalLinks = [
    {url = "www.notbaseurl.com", text="external site 0"},
    {url = "www.notbaseurl.com", text="external site 1"}
  ]

I also went into the layouts --> index.html and added this call to the external links

{{ $myLink := index .Site.Params.externalLinks 0 }}
          <a href="{{ $myLink.url | safeURL }}" target="_blank" rel="noopener">{{ $myLink.text | safeHTML }}</a>

For some reason after I build the page, the website generated still includes "front matter"

Link on external page will displays www.baseurl.com/externalwebsite

What I want to be linked is just externalwebsite.com

1

There are 1 answers

0
Mr. Hugo On

You can just write the links directly in the index.html file. You do not need to use the Hugo templating language. Another solution might be to start your links with 'https://' instead of just 'www'.

PS. This is not what we call 'front matter'.