[SOLVED] Site URL in index.html still points to example.com... why?

I’m new to Hugo (and git. And github), so I’m not sure how to look this problem if it is solved (probably).

I pushed my site to github at https://github.com/jarss/TAONAW/. Locally, works fine. Online though, I saw CSS link is broken. Not only that, it can’t find my posts even though there’s index.html in the right path (so it seems).

I changed siteurl to point to the right location, but still nothing. Not sure what’s going on. My theory is that something’s wrong with the theme since I used submodel before and now, I did not. Reason is again, I’m totally new to git and all of that so in an attempt to wrap my head around everything, I want to do it simple at first.

This is all theory, maybe if someone goes to my repo the mistake will be a big obvious typo or something (I hope!) which I missed.

so… um… help? And thanks in advance!

It helps if you post the link to your repo here that someone can have a look and make suggestions.

I did, it’s above: https://github.com/jarss/TAONAW/

Oh, sorry, didn’t look close enough.

1 Like

I am unable to reproduce that error.

When I clone and run hugo, I see the BaseURL inserted fine:

@@ -11,10 +11,10 @@
   <title>404 Page not found &middot; The Art of Not Asking Why</title>
 
   
-  <link type="text/css" rel="stylesheet" href="http://example.org/css/print.css" media="print">
-  <link type="text/css" rel="stylesheet" href="http://example.org/css/poole.css">
-  <link type="text/css" rel="stylesheet" href="http://example.org/css/syntax.css">
-  <link type="text/css" rel="stylesheet" href="http://example.org/css/hyde.css">
+  <link type="text/css" rel="stylesheet" href="https://jarss.github.io/TAONAW/css/print.css" media="print">
+  <link type="text/css" rel="stylesheet" href="https://jarss.github.io/TAONAW/css/poole.css">
+  <link type="text/css" rel="stylesheet" href="https://jarss.github.io/TAONAW/css/syntax.css">
+  <link type="text/css" rel="stylesheet" href="https://jarss.github.io/TAONAW/css/hyde.css">
   
 
 <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Montserrat+Fatface|PT+Sans:400,400i,700"> 
@@ -34,7 +34,7 @@
   <aside class="sidebar">
   <div class="container sidebar-sticky">
     <div class="sidebar-about">
-      <a href="http://example.org/"><h1>The Art of Not Asking Why</h1></a>
+      <a href="https://jarss.github.io/TAONAW/"><h1>The Art of Not Asking Why</h1></a>
       <p class="lead">
        An Attempt to Switch from WordPress 
       </p>
@@ -42,7 +42,7 @@
 
     <nav>
       <ul class="sidebar-nav">
-        <li><a href="http://example.org/">Home</a> </li>
+        <li><a href="https://jarss.github.io/TAONAW/">Home</a> </li>
         
       </ul>

How are you running hugo (the exact command)? I simply ran hugo.


Update: I also see that you did not use the latest Hugo version (I see that you used Hugo 0.40.1). I’d recommend using the latest Hugo version (0.49, as of today) from https://github.com/gohugoio/hugo/releases.

I looked into the repo. I tried to host it on my server and it works. But I made a change:

I created an additional config_prod.toml with just the entry baseurl = "https://jarss.github.io/TAONAW/" and changed in config.toml the Base URL to baseurl = "/".

I started Hugo for development with hugo server and for production with hugo --config config.toml,config_prod.toml. That gives me productions files with the url <link type="text/css" rel="stylesheet" href="https://jarss.github.io/TAONAW/css/print.css" media="print"> and so the CSS files should be found.

Give it a try and let me know whether it works.

Here are the 2 gists:
config.toml: https://gist.github.com/Lego2012/cf537db81cfb25face5fcc7123f6df1e
config_prod.toml: https://gist.github.com/Lego2012/ffea353887c392a0ffd5c97744aebd62

Why is that needed? The baseurl set by the OP in config.toml looks fine:

baseurl = "https://jarss.github.io/TAONAW/"

Hmm I forget how I installed Hugo at the time, but it was through their official docs instructions. I do know though that my previous attempt (the repo is still there under example 3 I believe) does work fine, believe with the same settings and same version.

Also, I just used “hugo” in the root of my site to generate the public (now docs) folder.

Just tried to produce a running production build. In my projects I usually have 4 different configs: config.yaml, config_local.yaml, config_stage.yaml and config_prod.yaml. That gives me the flexibility to create the URLs I need in the different builds.

For the local builds I want to have URLs like ./css/styles.css. Without a special config for local build I wouldn’t get that kind of URL.

So it’s working now?

From the introduction post, the OP is very new to Hugo and mainly, if the existing config works (at least for me), why make it complicated?

@jarss

Hmm I forget how I installed Hugo at the time

Depending on your OS, just download the latest release from Releases · gohugoio/hugo · GitHub, extract and run the binary from there. Fortunately, there’s not much involved when it comes to installing Hugo :slight_smile:

You can then go another mile and put that downloaded binary in one of the directories that exists in your system PATH environment variable.

A guess why it doesn’t work for you, but works for me… do you have a HUGO_BASEURL env var set to “http://example.com”?

What does echo $HUGO_BASEURL give? (assuming unix type OS. Don’t know how to print env vars on Windows.)

In any case, try brute-forcing the baseURL from the command line using:

hugo -b https://jarss.github.io/TAONAW/  

That should at least work.

@jarss

Additionally, what does this print?

hugo config | grep -i base

If you don’t have grep on your system, paste the complete output of:

hugo config

One more thing… unrelated to your issue, but you don’t need these in your config.toml (there are meant to be in a theme’s theme.toml. So they are useless in config.toml):

name = "Hyde"
license = "MIT"
licenselink = "https://github.com/spf13/hyde/blob/master/LICENSE.md"
description = "hara kiri"
tags = ["blog", "company"]
features = ["blog", "themes", "disqus"]
min_version = 0.21

# If Porting existing theme
[original]
    author =  "mdo"
    homepage = "http://markdotto.com/"
    repo = "https://www.github.com/mdo/hyde"

should try SSHing back home and try that, I hope it won’t mess up the website I already have with Hugo.

I don’t have a HUGO_BASEURL (at least not that I know of), the only var I know about is the siteurl.

When you view my index.html in the /docs root folder, you can see it points to example.com (I’m not sure if that’s what you did, I assume so) - that’s why I have this issue I believe.

When I run HUGO_BASEURL - command not found (I tried this from my site root as well).

edit… a minute in after sshing and doing what you suggested…

I did what you suggested:

hugo -b https://jarss.github.io/TAONAW/ 

THAT worked. I can see in my html the right URL now.

So I’m not sure what went wrong or if it will happen again…

It’s definitely something in your environment or something that you don’t have committed in your git.

Humor me… later when you go home, clone that repo to a different dir, and run hugo. Does that issue happen there too? If so… it’s something in your env.

I see this now, after I ran the currection you suggested, so it might have been overwritten.

Which correction?

I ran

hugo -b https://jarss.github.io/TAONAW/ 

which re-generated the site… but that’s not related, I see now. it won’t affect the config.

The grep you asked me to run shows my baseurl config, which was always set correctly (you can see it in the repo) so that wasn’t the problem, right?

I can do that…

it’s git clone original repo new repo right?

yeah:

git clone https://github.com/jarss/TAONAW
cd TAONAW
hugo

so the index.html shows the correct URL after I cloned and ran hugo (just hugo).

If I understand this correctly, even though the github repo has the “good” HTML file, hugo would overwrite it with the “bad” URL after running $hugo in the cloned repo root.

Well, I do have the valid URL in my index.html in the site root now… so what the heck was it? Mayne I should push to another repo to see?

At this point I think I want to work on my first posts and start working on the blog itself… I have a growing list of things I need to add/configure in the new Hugo site that I need to learn… :slight_smile: