How to get absolute/canonical path to my webpage?

I use Hugo (v0.47) via R blogdown package (v0.8.3) with Hugo theme Lithium ( through RStudio IDE.

In config.toml I added the lines:

baseurl = ""
canonifyURLs  = true

Then I try to get the URL to my webpage by using:

{{ .Site.BaseURL }} <br>
{{ .Site.BaseURL | absLangURL }} <br>
{{ .Site.BaseURL | absURL }} <br>
{{ .Site.BaseURL | relLangURL }} <br>
{{ .Site.BaseURL | relURL }} <br>

Each line resolves to / and I expect either or in some cases.

I even tried the first example from

{{ "mystyle.css" | absURL }} <br>
{{ "mystyle.css" | relURL }} <br>

In both cases, the result is identical: /mystyle.css, and the example shows that the result should not be identical.

My questions:

  1. Is this behavior expected?
  2. Am I missing something?
  3. How can I get absolute/canonical URL?



Both result in /

OK, then you need to show the souce. I suspect you have configured the baseURL incorrect.

I’m not sure what exactly “source” means in this context. But I created a temporary GitHub repo for debugging. In this commit you see the changes I made to the downloaded theme after I installed it (the previous commits are only the creation and update of “public” folder). Two lines I modified in “config.toml”:

baseurl = ""
canonifyURLs  = true

And other lines for debugging. I chose this theme as an example as it is quite simple. But the same issue persists with other themes I tried too.

p.s. I tried writing baseurl as well as baseURL. The result is the same.

@GegznaV, I put yer code in a table. I don’t know about yer issue, but it makes it a bit easier to read:

<!-- BEGIN (for debugging) -->
<tr><td>.Site.BaseURL</td><td>{{ .Site.BaseURL }}</td></tr>
<tr><td>.Site.BaseURL | absLangURL</td><td> {{ .Site.BaseURL | absLangURL }}</td></tr>
<tr><td>.Site.BaseURL | absURL</td><td>{{ .Site.BaseURL | absURL }}</td></tr>
<tr><td>.Site.BaseURL | relLangURL</td><td>{{ .Site.BaseURL | relLangURL }}</td></tr>
<tr><td>.Site.BaseURL | relURL</td><td>{{ .Site.BaseURL | relURL }}</td></tr>
<tr><td>.Permalink</td><td>{{ .Permalink }}</td></tr>
<tr><td>.Permalink | absLangURL</td><td>{{ .Permalink | absLangURL }}</td></tr>
<tr><td>.Permalink | absURL</td><td>{{ .Permalink | absURL }}</td></tr>
<tr><td>.Permalink | relLangURL</td><td>{{ .Permalink | relLangURL }}</td></tr>
<tr><td>.Permalink | relURL</td><td>{{ .Permalink | relURL }}</td></tr>
<tr><td>.Site.Home.RelPermalink</td><td>{{ .Site.Home.RelPermalink }}</td></tr>
<tr><td>.Site.Home.Permalink</td><td>{{ .Site.Home.Permalink }}</td></tr>
<tr><td>"mystyle.css" | absURL</td><td>{{ "mystyle.css" | absURL }}</td></tr>
<tr><td>"mystyle.css" | relURL</td><td>{{ "mystyle.css" | relURL }}</td></tr>
<!-- END (for debugging) -->