URL doesn't work as I thought it would

Hi,

I do not understand why the condition work with a local link written on my own and it dosen’t with a variable that have exaclty the same render as my written like.
That code works, it displays links on the page http://localhost:1313/

     {{if eq "http://localhost:1313/" .Permalink }}
		<p> .Site.BaseURL : <br> {{.Site.BaseURL}} </p>
		<p>url : <br> http://localhost:1313/</p>
	{{ end }}


That one does not work

{{if eq .Site.BaseURL .Permalink }}
	<p> .Site.BaseURL : <br> {{.Site.BaseURL}} </p>
	<p>url : <br> http://localhost:1313/</p>
{{ end }}

Someone has some informtion that can make me understand that ? Thanks :slight_smile:

I don’t understand what you want to do

You can use

.Site.IsServer

to check, if hugo is running on localhost

Hi,

.Site.BaseURL is of type template.URL, while .Permalink is of type string.

.Site.BaseURL : {{  printf "%#T" .Site.BaseURL}}
<br> 
Permalink: {{ printf "%#T" .Permalink }}

If you are trying to test if the current page is the home page, you can instead try .IsHome:

{{ if .IsHome }}
3 Likes

Thank you for the explication