URL doesn't work as I thought it would


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


to check, if hugo is running on localhost


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

.Site.BaseURL : {{  printf "%#T" .Site.BaseURL}}
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 }}

Thank you for the explication