How to get markdown _markup site url

When I try to call the site address in the Markdown _markup, I get an error. Is there any solution for this?

Error:

execute of template failed at <.Site.BaseURL>: can’t evaluate field Site in type goldmark.linkContext

1 Like

.Site is not in context.

Use either of these instead:

{{ site.BaseURL }}
{{ .Page.Site.BaseURL }}
2 Likes

thank you for solving my problem. But I wondered something, why doesn’t it add https:// as output?

1 Like

Are you looking at the output from hugo or hugo server?
What is the baseURL in your site configuration?

2 Likes

When I typed {{ .Page.Site.BaseURL }} it gave me //localhost output, probably because I am on localhost. When I install it on my website, I think it will add it per https://. Thanks again for your reply.

1 Like

If you are seeing this:

//localhost

Then your baseURL is either empty or /. Neither of those are valid.

The baseURL should be the fully qualified URL to your production site, with a trailing slash.

https://www.example.org/
https://something.github.io/my-project/
2 Likes

Thank you for your answer.

1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.