Hugo: inconsistent {{ .Site.BaseURL }} results

Created on 25 Jan 2020  Â·  4Comments  Â·  Source: gohugoio/hugo

What version of Hugo are you using (hugo version)?

$ hugo version 0.63.1

Does this issue reproduce with the latest release?

yes

When running hugo serve -D --buildDrafts --buildFuture -disableFastRender, {{ .Site.BaseURL }} returns http://localhost/.

When running with Netlify, it returns https://dev--jasik-xyz.netlify.com with no trailing slash.

This could be an implemenation inconsistency between Netlify and hugo, but maybe rewriting double slashes to single slashes would be the right move?

https://github.com/jasikpark/jasik-xyz/commit/0814c7a0f6ac27864079678ad8979a18cc5e4c28

All 4 comments

@jasikpark
I am sure that the implementation will be same but the build settings are different between Netlify and local server.

  • $DEPLOY_PRIME_URL in netlify.toml has no trailing slash
  • Hugo's local server's base url has a trailing slash

Hugo already has some solutions for this problem.
For example you can write this with absURL like

<a rel="me" href="{{ "/about/" | absURL}}">About</a>

Or, in this case, you can just remove {{ .Site.BaseURL }}

<a rel="me" href="/about/">About</a>

Ok, cool — I’m definitely looking for the absURL function in that case!

Caleb Jasik
[email protected]
https://jasik.xyz

On February 15, 2020 at 2:20:14 PM, satotake ([email protected]) wrote:

@jasikpark
I am sure that the implementation will be same but the build settings are different between Netlify and local server.

$DEPLOY_PRIME_URL in netlify.toml has no trailing slash
Hugo's local server's base url has a trailing slash
Hugo already has some solutions for this problem.
For example you can write this with absURL like

About
Or, in this case, you can just remove {{ .Site.BaseURL }}

About
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or unsubscribe.

We only modify the `baseURL´ when running the server.

@jasikpark if you are ok, could you close this?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

moorereason picture moorereason  Â·  3Comments

sigma picture sigma  Â·  3Comments

marekr picture marekr  Â·  3Comments

vielmetti picture vielmetti  Â·  3Comments

VoidingWarranties picture VoidingWarranties  Â·  3Comments