Hugo site returning 404 not found for new posts

I have a Hugo website here lf0 ( dot)com

The github repo can be found here: https://github.com/msmith01/msmith01.github.io/

I recently created a new blog posts and when I run (in R Studio) blogdown::serve_site() the site builds and I can access it from 127.0.0.1:4321 where the new blog post has been uploaded and everything looks okay. I then push the site to github to upload the new blog post. However I get a 404 not found:

https://lf0.com/post/machine-learning-boundary-conditions/machine-learning-boundary-conditions

But the blog post exists on the github repo

blob/master/post/Machine-Learning-boundary-conditions/machine-learning-boundary-conditions/index

I did make some recent changes to the rss in themes\hugo-academic\layouts_default - could this be the issue?

The old posts work fine, just the new posts obtain the 404 not found.

Hi there,

Just guessing here: probably a URL case issue. Your generated site on github has it at post/Machine-Learning-boundary-conditions while you are accessing post/machine-learning-boundary-conditions. It is, in fact, available, at https://lf0.com/post/Machine-Learning-boundary-conditions/machine-learning-boundary-conditions/

Have a look at disablePathToLower.

Also, for future reference, it is generally more helpful to post your site source repo (with the markdown files), not the repo for the generated html files.

1 Like

Thanks for the quick reply. I see the post is working at the url you posted. I also understand why all my other posts were carefully put into lower case folders and file names. I accidentally made this post contain some upper case characters.

Can I just put:

disablePathToLower = True

into the config.toml? I am looking in the config.toml file and cannot see any reference to disablePathToLower.

I still cannot seem to get the post to display correctly. It keeps saying 404 page not found, I have modified the config.toml file with no success. I have also renamed the folder to all lower case.

Hi there,

As I mentioned above, at the moment it’s a guess. Maybe it was that, maybe there’s something else going on. It would be helpful to see your site source repo, not the generated site repo. Have a read about Requesting Help .

The source repo can be found here: https://github.com/msmith01/master_msmith01.github.io

It is a little old (5 months old) since I cannot seem to β€œupdate” the github repo at the moment.

So I’ve had a look at your repo.

It does not have that example post that you mention above, so I did:

  • hugo new post/ThisHasCaps/index.md
  • run hugo
  • inspect public:
public/post/
β”œβ”€β”€ thishascaps
β”‚   └── index.html
...
  • inspect public/post/index.html (yoursite.com/post/):
<a href="/post/thishascaps/" >ThisHasCaps</a>

Then:

  • edit config.toml
  • add disablePathToLower = true
    • make sure to add this line before the toml tables start (ie [outputs])
  • run hugo
  • inspect public
public/post/
β”œβ”€β”€ ThisHasCaps
β”‚   └── index.html
...
  • inspect public/post/index.html
<a href="/post/ThisHasCaps/" >ThisHasCaps</a>

I am running 0.65.3. Do you get a different result?

Thanks for your help!

I managed to get the blog post I wanted working buy re-creating it using lowercase folder names and post names. Now the post works at the URL:

And is linked up well on the homepage.

I added the line you suggested:

# Name of Academic theme folder in `themes/`.
theme = "hugo-academic"

# Get last modified date for content from Git?
enableGitInfo = false

# Remove case sensitive links
disablePathToLower = true                                   # HERE

# Default language to use (if you setup multilingual support)
defaultContentLanguage = "en"
hasCJKLanguage = false  # Set `true` for Chinese/Japanese/Korean languages.
defaultContentLanguageInSubdir = false
removePathAccents = true  # Workaround for REMOVED URL 

Now I get an eror 404 for the following (old) post:

https://lf0.com/post/xgboost-time-series-classification-trading-strategy/XGBoost-time-series-quant-trading-strategy/

When I set the following to true: disablePathToLower = true the following links breaks.

https://lf0.com/post/xgboost-time-series-classification-trading-strategy/XGBoost-time-series-quant-trading-strategy/

and

https://lf0.com/post/portfolio-optimisation-model/portfolio-optimisation-R/

I can only guess it’s because of the XGB and the R in the links.

However, I reconstructed the original post (which was causing problems) and saved the folders and file names in lower-case and I am able to have all links working (including the XGB and R titled one).

If you know of a solution for this, please let me know but in the mean time I (think) I have a working solution.