HUGO

Fuji2 Theme - Top banner isnt' redirecting to home page

I am relatively new to Hugo and I have been using Fuji2 Theme and hosted my website in Netlify

I have a strange issue happening on the site hosted on Netlify, where clicking on the Top Banner (‘Blogs Of Raghs’) is NOT taking me to the home page as expected to be, but it stays on the current URL/post itself. However it works fine on the localhost.

Any idea as to how I get it resolved? Should I need to any setting on the netlify hosting?

Cheers,
RM…

We also need to see your actual site code, not just the theme. It is probably a configuration setting.

Do you have your baseURL configured correctly?

HI @pointyfar , thanks. I followed the configuration as suggested for Netlify hosting , as follows in config.toml file as follows.

baseURL = ""
languageCode = "en-us"
title = "Blogs of Raghs"
#theme = "ananke" 
theme = "fuji"

Does it have to do anything? But it works fine my local host.

Cheers,
RM…

This is how the link is built: hugo-theme-fuji/header.html at master · dsrkafuu/hugo-theme-fuji · GitHub

So, if baseURL = "" , then href=""

@pointyfar , I tried it. But still no luck. How come it works locally but not on Netlify ?

My current config.toml looks like the below.

baseURL = ""
href = ""

When you run hugo server, it automagically sets baseURL = localhost:1313 for you (i.e. it overrides whatever you’ve got in your configuration).

You should set baseURL to the domain it’s hosted on Netlify. (And don’t worry if at the moment you’re using one of their weird URLs - you can always change it later.)

1 Like

Thanks for the insights @funkydan2 . Let me try that and update you shortly.

@funkydan2 , thanks a lot :slight_smile: :blush: it worked like a charm. Thank you. I read somewhere while deploying my site to Netlify that the settings should be left blank and hence I followed that. This has actually caused the issue. Now I added the site name to the baseURL property in the config.toml file with my website URL and it works perfectly on both the localhost as well as well the website hosted on Netlify.

One QQ if you can help me understand this nuance a bit. How does Go/Hugo set the localhost reference for the local site despite the configuration is set with my external site? :wink: :face_with_monocle: :worried:

Additional Q (updated): The settings on the baseURL in the config.toml works fine on the local site as well as the main host (the actual name where I have redirected the nameservers for my domain - https://raghsonline.com). But it broke the URL for the name given by Netlify (https://raghsonline.netlify.app/) where the banner redirects always to the main external domain (https://raghsonlie.com) and NOT to the https://raghsonline.netlify.app. Why? :worried: :face_with_monocle:

Cheers,
RM…

This is pretty easy. Your site’s url is just a line in a text file baseURL = https://raghsonline.com. When you run hugo server the hugo binary runs a testing webserver (normally bound to localhost:1313 and builds your site (in memory) for that server to serve. When it’s in ‘testing’ mode, it builds your site (in memory) using baseURL = localhost:1313 (or whatever port the server is running on).

When you (or netlify) run hugo and builds the site to disk, the hugo binary doesn’t overwrite the setting you have in your config file. It uses it, and puts that value wherever .Site.BaseURL is in the layouts of your site.

1 Like

It isn’t broken. It’s done exactly what you’ve told hugo to do. When netlify builds the site, wherever .Site.BaseURL is in the layouts, it puts the value https://raghsonline.com. And so on your site, no matter from which URL you visit (your purchased domain or the netlify subdomain) that’s what the link is in your header.

If I was you, I’d set up redirection in Netlify so if anyone visits your site using the netlify subdomain, they’ll be automatically redirected to your purchased domain name.

1 Like

Got it. Thanks @funkydan2 . It is what you had mentioned elsewhere in the earlier post as auto*magic*ally :blush: It is to deal with the internals of Hugo Runtime.

Cheers,
RM…

Perfect and I am completely fine with this. Thank you very much.

Thanks @funkydan2. It is kinda convincing but still not very much clear. I wish this settings in the Netlify subdomain should be inclined similar to the localhost. Is this a fair ask? or I am asking something impractical - conceptually?

As you explained, the magic happens only for the localhost, despite the different configuration. Is it?

Cheers,
RM…

So this is probably getting outside the scope of this forum - more suited for the Netlify forums, or a general networking forum…but I’ll give it a go by way of analogy.

The church I attend is legally called ‘Crown Road Presbyterian Church’. That’s the name of the bank accounts etc. However, everyone calls it ‘Gympie Presbyterian Church’ (Gympie is the name of the town/city it’s in) because it’s the only Presbyterian Church in the town, and Crown Road is meaningless for most people.

So, if someone says ‘take me to Crown Road Presbyterian Church’ or ‘take me to Gympie Presbyterian Church’ on a Sunday, they’ll end up at the same location. However, when they get to the building, no matter what name they used for directions, they’ll see the words ‘Gympie Presbyterian Church’ written everywhere.

Your site is similar.

There are two ‘names’ (URLs) you can call it by. You can ask your web browser to take you to either URL, and since URLs are resolved to IP addresses, they’ll end up taking you to the same website (i.e. the same HTML, js, and css files will be delivered to your browser). Depending on the code you’ve used to build your website (for this situation, the code built by hugo using your configuration file) any link which uses .Site.BaseURL or anywhere that .Permalink appears in your layouts, will have in the resulting HTML whatever you’ve set as baseURL in your configuration file. Back to the analogy - no matter which name you use to get there, the building will have the same sign on the side.

Does that help?

Yeah, I get it @funkydan2 . Thank you very much. The confusion is mainly due to the special consideration on the localhost I guess, which is where the magic happens behind the scenes by the Hugo Runtime. Rest all, works the same way. Is that a fair conclusion we can make?

Cheers,
RM…