On path "/" page not found but "/index.html" it opens

the address

mywebsite.com/post/my-post/

is serving by default

mywebsite.com/post/my-post/index.xml

instead of

mywebsite.com/post/my-post/index.html

if I manully go to address mywebsite.com/post/my-post/index.html then I can see my blog post. What settings needs to be changed to point it to index.html without ugly urls?

Are you looking at it on the local host, e.g.: localhost:1313?

That’s strange. :slight_smile:

Please share your site’s code so we can check what’s up.

I just checked again. Its not happening at localhost but at the actual domain.

I had made few mistakes with this website.

  1. The base url at site config was incorrect (Fixed it)
  2. 404 page was not defined (Fixed it)

So actually its not showing getrichwithabudget.com/posts/test/index.xml but it was actually looking for 404.html and it couldn’t find it.

Now its showing 404.html at getrichwithabudget.com/posts/test/ but if you go to getrichwithabudget.com/posts/test/index.html then you see the post.

baseURL: https://getrichwithabudget.com/
languageCode: en-us
title: Apoorv Blog
enableEmoji: true
enableGitInfo: true
enableInlineShortcodes: true
enableRobotsTXT: true
paginate: 5
relativeURLs: true
sectionPagesMenu: main
uglyurls: false
markup:
  goldmark:
    renderer:
      unsafe: true
  highlight:
    lineNos: true

Glad you solved the base url issue.

The 404 error might be happening because you are missing a layout for your posts. Make sure that you have the following files in your layouts directory:
|-- layouts
| |-- posts
| | |-- [ ] list.html
| | |-- [ ] single.html

See [Base Templates and Blocks]( https://gohugo.io/templates/base/

I have not started making any complex layouts yet. Still using basic architecture as follows.

|-- layouts
| |-- _default
| | |-- [ ] baseof.html
| | |-- [ ] list.html
| | |-- [ ] single.html

So basically layout is same for each “single” page. Why am I still getting 404 at “/” then?

Please post a link to the public repository for your site. See:
https://discourse.gohugo.io/t/requesting-help/9132

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.

I have moved away from Github and using Code commit for CI CD with AWS Codepipeline and other resources. I am keeping code commit private. But I copied the code and published to github for this question.

It’s a webserver configuration problem. You can change your default index page on your web server. For example with Apache:

<IfModule dir_module>
    DirectoryIndex index.html index.php
</IfModule>

As I mentioned earlier I am deploying to AWS. Specifically S3 with cloudfront cache. Also website is not served via S3 but its served exclusively though Cloudfront. And I have set defaultRootObject to be index.html. There is no other webserver configuration available in S3 or Cloudfront. If there is then please let me know.

Aparantly this is a known bug in cloudfront. Other users have faced same issue. There is temporary workaround given in the blog post but its not working for me.

The actual solution is to uglify the urls. and have full page.html for each page.

EDIT

This resource was also helpful:
https://github.com/riboseinc/terraform-aws-s3-cloudfront-website/issues/1

Here? https://docs.aws.amazon.com/AmazonS3/latest/dev/IndexDocumentSupport.html

This sounds like a question about configuring web servers, which is off topic for this forum. Closing this now.

2 Likes