.Permalink not including domain on Netlify

I’ve been working on what will be a large consumer site for a year or so. We’re a couple of months away from going live. Up to this point, I’ve been using “hugo server”. There’s a repository so I can just commit and push the changes to BitBucket, which is connected to the Netlify account. Every single thing has worked as expected.

Yesterday, I needed to be able to grab the Permalink version of the current Page in order to construct shareable URLs for Facebook icons. I was running into issues with that and strongly suspected that a context was not being passed but I didn’t know why. Thankfully, J Mooring solved my problem almost instantly by asking if I was using . to pass the context. Duh! I didn’t know about that but it solved the problem. On my local site, I was able to get the Permalink and easily construct the URLs that I needed.

This morning, I exported the changes to Netlify and was surprised to see the domain portion of the Permalink missing. Essentially, Permalink was returning the same thing as RelPermalink. Since the test site is password-protected, I thought maybe that was causing a problem. (Not really, but it was easy to test. :grinning:) Temporarily removing the password made no difference.

I started searching for why that might be happening and found a question here that basically told someone that they needed to use “Hugo” instead of “Hugo Server” to get a correct production deploy. I didn’t know that existed, either. It’s amazing how much you can get done with Hugo and still be missing some critical concepts.

I used “Hugo” to build the site and uploaded that to Bitbucket and thence to Netlify. Expecting to have solved my own problem, I eagerly tested it and saw that there was no change.

I searched farther and saw references to making certain that config.toml has baseURL correctly defined. It does.

I strongly suspect that I’m missing some simple concept but, for the life of me, I don’t know what it is.

I recognize the possibility that this is a problem on the Netlify end and will pursue this with them if it gets to that. I’m just thinking it’s more likely to be my error.

Any suggestions are gratefully accepted. :slight_smile:

Thanks,
Brian

What is the value of baseURL in your site configuration?

What does your netlify.toml file look like?

Feel free to DM if you are not comfortable sharing this publicly.

I want to identify the solution to my question for the sake of others who might run into the same problem in the future.

Joe found my problem almost instantly. :slight_smile:

My netlify.toml file contained the following line in the [build.environment] section:

HUGO_BASEURL = “/”

Joe wrote: “And there’s the problem. This overrides the value in Hugo’s config file.”

I deleted that line, saved the file, pushed the change to Netlify and everything started working as expected. Once again I need to publicly thank Joe for his help.

2 Likes

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