Having trouble adding (custom domain to) hugo site on gh-pages

Hi,

I have been following the directions for pushing a hugo site to Github gh-pages and then adding a custom domain to it. However, the directions seem to be wrong. This is what I am talking about specifically:

Building and Deployment

Now check out the gh-pages branch into your public folder, using git’s worktree feature (essentially, it allows you to have multiple branches of the same local repo to be checked out in different directories):

rm -rf public
git worktree add -B gh-pages public upstream/gh-pages

So I am successful in creating a gh-pages, but nothing actually gets pushed there. It remains an orphan empty branch. My ultimate goal is to take my newly created hugo static site that was originally (and technically still is until I successfully complete pointing my domain to gh-pages) on WP and host it on gh-pages via Hugo. Anyone else have similar issues?

For example:

git worktree add -B gh-pages public upstream/ gh-pages

usage: git worktree add [<options>] <path> [<branch>]
   or: git worktree list [<options>]
   or: git worktree lock [<options>] <path>
   or: git worktree prune [<options>]
   or: git worktree unlock <path>

    -f, --force           checkout <branch> even if already checked out in other worktree
    -b <branch>           create a new branch
    -B <branch>           create or reset a branch
    --detach              detach HEAD at named commit
    --checkout            populate the new working tree

Update: I found the following thread which has half-gotten me there (so far): https://discuss.gohugo.io/t/simple-deployment-to-gh-pages/5003

Update: I am having trouble with “upstream” part:

git push upstream gh-pages
fatal: 'upstream' does not appear to be a git repository
fatal: Could not read from remote repository.

Hi @interglobalmedia,

Sorry, I have not tried this method at all, since I’m publishing to webfaction.
Does “upstream” exist, or, is that word being used to mean a generic “use the upstream branch name”?

Wild guess, what about:

git push origin gh-pages

Would this help? https://pages.github.com/
May be useful to merge that info with your notes on the process, since it is possible the hugo docs are outdated.

Hi @RickCogley, Thanks for the response and feedback! Upstream actually refers to origin, meaning your remote repo branch you are pushing to. So if you are on master locally and you want to push your changes to the remote branch, you would type git push origin master to your remote master branch. I do think that the Hugo notes are a bit outdated. It made it initially a bit confusing, but then I double checked on Stack Overflow and got the answer(s) I sought. So what I did was replace upstream with origin, and everything worked as it should.

In addition, I think I have found the answer(s) I needed regarding adding a custom domain to the repo. I won’t be able to try it out until later tonight, but will provide the info when I am successful, which I should be.

Update: I did what I thought would result in my custom domain pointing to my Hugo site hosted on Github, but when I checked to see whether or not my set up was successful, I got the following in iTerm2:

dig interglobalmedianetwork.com +noall +answer                        ✹

; <<>> DiG 9.8.3-P1 <<>> interglobalmedianetwork.com +noall +answer
;; global options: +cmd
interglobalmedianetwork.com. 14400 IN	A	192.30.252.154
interglobalmedianetwork.com. 14400 IN	A	192.30.252.153

And then

dig interglobalmedia.github.io +noall +answer                         ✹

; <<>> DiG 9.8.3-P1 <<>> interglobalmedia.github.io +noall +answer
;; global options: +cmd
interglobalmedia.github.io. 3600 IN	CNAME	github.map.fastly.net.
github.map.fastly.net.	9	IN	A	151.101.20.133

So this means that the custom domain is pointing to the right IP address, but not the repo. In my config.toml, I have the following:

baseurl = “https://interglobalmedia.github.io/

But when I had “http://www.interglobalmedianetwork.com” as the baseurl, it only worked when I had my WordPress install active on my hosting service, which is what I DON’t want. In my CNAME, I have “interglobalmedianetwork.com”. I’m waiting to hear back from Github, since they purportedly gave me info that was supposed to result in a successful set up. However, it was not.

Well, still haven’t figured out my situation. Github hasn’t provided me with correct info. Hugo documentation definitely has not. And no answers yet here either. I have spent way too much time trying to figure something out which probably entails a tiny tweak somewhere (because my local site is just fine). I’m abandoning this for now, because bigger things are being neglected. I’ll just have to deal with not having this website until I get my answers wherever. One thing is for sure. When I do get my answers, I will be writing up documentation for myself so that I never have to go through this again. WP may not be greatest, but it sure was easy to get it going compared with the time I wasted trying to get a custom domain with this Hugo static site. The lack of clear documentation both on Github and Hugo has made things very difficult when they should not have been.

Can’t help you with Github Pages I’m afraid.
But if you ever consider Gitlab Pages, it’s pretty straightforward to host a Hugo site with automatic deployment.

I already have two Hugo sites deployed with Gitlab Pages and I am pretty happy.

Just noticed this. I don’t think you should have your Github subdomain as a baseurl if you want your repo to be served under your own domain.

Have you tried setting your baseurl to your domain without www?
Have you checked if Github Pages supports naked domains?
If they don’t you must create a www CNAME record that points to Github, so that your repo is served.

Just my two cents.

@alexandros Thanks so much for reaching out. I have been back and forth with Github, and just spelled out that I wanted an apex domain (is that the same as naked domain? ie, http://(www or not).domainname.com, and am awaiting their reply. Because it is not a subdomain I am looking to create. It’s a top level domain. Because that is what I have had to date and want to keep. Perhaps Github won’t be the answer after all. It’s just that it is free, and I don’t need any backend right now. Do you have to pay anything for Gitlab? Because there are also things like Netlify which do everything for you (Hugo docs are hosted there), but it is not free. And I will have several sites I am migrating from WP, so it all adds up. We’ll see what Github has to say.

I tried many different urls with the baseurl. They all did not work. Github is telling me they can see my sight. I don’t know how that is possible.

As per Github Pages help section they do support apex domains
https://help.github.com/articles/using-a-custom-domain-with-github-pages/

I can see your site also. It’s this one isn’t it?
http://interglobalmedianetwork.com/

My guess is that your browser’s cache is playing tricks on you. Either clear it. Or open an incognito tab and visit your site. You should be able to see it.

1 Like

Hi @alexandros, the site IS up now. However, it took a long time to happen. Even after Github was able to see it, I wasn’t until later. Very strange. Maybe a Github thing. Now I just have to update the links to my posts and pages.

@alexandros I updated my links, but what is bizarre is that my site immediately updates and renders on my iphone, but is still blank on my laptop. Why would that be? This is really strange. And not the best situation when one wants to add content. It may be that mobile is updated immediately but not laptop or desktop for whatever reason. I would have to test on other devices to confirm this.

Did you clear your browser’s cache on your laptop? Are you using a modern browser? Also there was a delay for your site to go live because DNS takes a while to propagate. It wasn’t Github’s issue.

@alexandros sure did. Multiple times. But I just came across this interesting article about my problem:

https://customercenter.karthost.com/knowledgebase/70/Clearing-Your-IP-Cache-on-your-local-Computer.html

Am going to do what they suggest. Sounds exactly like what is going on and what I suspected, just didn’t know how to fix it. Hopefully this solution will be successful. Because I checked to see what IP addresses the world was seeing for the site, and they indeed were seeing the correct Github IP addresses. Just my local computer is not. According to the article, the cache is probably in the router.

Worst case scenario (which might be mine because I have had similar cache issues in the past which I never quite understood till now), I might just have to wait for the router to resolve itself.

Final update: It was an IP cache, but the only way to really get rid of it is to go into the hosts file via nano editor. There you remove the old IP and replace it with the new one. Here is a good article on it: https://www.imore.com/how-edit-your-macs-hosts-file-and-why-you-would-want

And my final write up on the issue: http://interglobalmedianetwork.com/post/how-to-remove-cached-ips/