Local Server badly generates my website

Hello,

After having successfully used Hugo with the Hyde theme for a few years, I decided the other day to build a new website.

So, I followed the ‘quick start guide’ again and created a new hugo site in a ‘monblog’ folder. I added a theme, smol https://github.com/colorchestra/smol and started to write 2 or 3 articles, an about page, etc. Then I launched the local server using hugo server -D and went to http://localhost:1313/ to see it and it worked fine.

I changed a few things in my config.toml and in the smol theme to fit my needs, and the rendering was fine for me.

Then I stopped my local server with Ctrl+C and re-launched it with hugo server -D again, but this time it told me my website was viewable at:

hugo server -D
Start building sites …
hugo v0.87.0+extended linux/amd64 BuildDate=unknown

               | FR  

-------------------±----
Pages | 18
Paginator pages | 0
Non-page files | 0
Static files | 4
Processed images | 0
Aliases | 6
Sitemaps | 1
Cleaned | 0

Built in 43 ms
Watching for changes in /home/arnauld/monblog/{archetypes,assets,content,data,layouts,static,themes}
Watching for config changes in /home/arnauld/monblog/config.toml
Environment: “development”
Serving pages from memory
Running in Fast Render Mode. For full rebuilds on change: hugo server --disableFastRender
Web Server is available at http://localhost:1313/blog/ (bind address 127.0.0.1)
Press Ctrl+C to stop

And when I go to http://localhost:1313/blog/ I can see my main page, I can click my articles and read them ok, but a few links (about page, home, etc.) redirects me to a 404 page not found (for example if I click a link on my site which should redirect me to my homepage it redirects me to .http://localhost:1313/blog/ and another link which should redirects me to the same home page redirects me to http://localhost:1313/blog/ … However when I first generated my blog the two links were working fine and redirected me to my homepage. The changes happened when I stopped and re-launched my local server with hugo server -D

That’s very weird and I don’t understand why. Furthermore, as you can see above, the local server tells me to view my website at http://localhost:1313/blog/ . Blog was a local folder in which I set up a hugo website previously but I then deleted it. And my new website is in a ‘monblog’ folder.

Did Hugo mixed things, does it keep in memory previously generated website and mixed eveything?

I am confused and don’t understand why this is happening.

Thank you for any help.

Share your code. See:
https://discourse.gohugo.io/t/requesting-help/9132

Let us see your code

Include a link to the source code repository of your project, because we really need the context of seeing your templates and partials to be able to help you. It is trivial to do a quick git clone on your repo, then run hugo server in your project, to help you out. On the other hand, recreating your code from screenshots, or sort of guessing at it, is not.

If you can’t share your repository for whatever reason, consider creating a dummy repo that you can share, which reproduces the problem you’re experiencing.

This is happening because Hugo does not clean up after itsself. You removed or moved some pages (or changed their config), so they became 404’s. This became visible after restarting the Hugo server (because this restart cleared everything).

1 Like

Hello,

So I thought it was solved, I erased everything, folders. I created a new site in a folder ‘arnauld’ launched the sever with hugo server stopped it 2 or 3 times, address to see my site was http://localhost:1313/ and then suddenly after having stopped the server and re-launched it, it tells me the site is at http://localhost:1313/blog/

So it added /blog/ at the end and of course my site is partially broken.

I don’t understand why it added /blog/ at the end of the address…

See my previous response.

2 Likes

Thank you. What do you mean by

the source code repository ?

I am just running Hugo on my computer with a simple theme. What do you want me to share?

@jmooring is referring to a repository on Github, which is what many regulars here are using. If you set that up as a public repository, everyone can clone it and that way reproduce your problem. Hopefully.

Ok, thank you, I understand. I don’t use Github but I will try to set it up.
However I think my problem is more to do with Hugo by itself, at least for my computer. I am using Manjaro now and the last time I used Hugo was on Linux Mint and I didn’t encounter any difficulties.

To test again, I deleted my local website, and generated a new website with a different name, a different theme, created a few posts with pictures, launched the sever and everything went fine, I could acess the site at http://localhost:1313/ , images appeared fine.

Until I stopped the server, launched it again and, again, it tells me to view my site at http://localhost:1313/blog/ ( but why did it add blog at the end of the adress??), and again problems arise. This time the images don’t show up in my posts, just their description… My images are in the static folder and I add them with ![wuhan school](/school-hubei-wuhan-old.jpg )

Could it be that it is Hugo for the Manjaro distribution that may be faulty?

That’s very weird because I have used Hugo for more than 3 years for my personal blog without any difficulties…

Just zip up your source code and post it somewhere for us to download. Let us see your code.

You mean my whole folder containing my site?

Yes, the root directory of your project.

Here it is, I uploaded it on my own selfhosted little server: Jirafeau, your web file repository

Your config.toml file:

baseURL = 'https://arnauld.org/blog/'

You are telling hugo that your published files (the files created in the public directory when you run hugo) will be placed in the /blog/ directory of the site served at https://arnauld.org/.

The directory in which your source files reside is irrelevant.

When you run hugo server the published files are served from http://localhost:1313/blog/.

The “About” link in your menu results in a 404 because you have not created an “about” page in your content directory.

1 Like

Ok, thank you very much. I will change this when I am back at my computer. I thought the baseURL was the internet adress at which my website will be accessible when online. So what to put there as my blog will be accessible at this adress ‘Mon blog | Home’ when online ?

It is.

So what’s wrong ?

Nothing is wrong. I downloaded your zip file, extracted it, cd’d into the directory, then ran hugo server. Everything is functioning as it should.

But on my computer it is not working, I can’t see the images…

That’s because your image links are like this:

/school-hubei-wuhan-old.jpg

Instead of:

/blog/school-hubei-wuhan-old.jpg
1 Like

Ok, I see, I will change that. Thank you again for your help and patience :slight_smile: