I don't want the blog to be the first page that opens on my website

Hello everyone, new here but not to Hugo. :slight_smile:

I have been using the theme CodeIT for my blog. I am encountering a problem now that I want to introduce a change.

The theme, by default, shows the blog as soon as you open the website.

I want the first page to be shown to be a static page, something like an about page, and the blog to be accessible by clicking “Blog” in the menu.

By adding an index.html file in /layouts/, and an _index.md in /content/, I managed to override the default behaviour and the static page shows correctly.

My problem now is that I can’t move the blog to myblog.com/blog/.

Can someone help me with this problem? :pray:

Adding a _index.md in content/blog should do the trick. Still needs a layouts/_default/list.html but that one was probably already there.

Thanks for the reply. :slight_smile:

The problem I have now is: I don’t know what kind of _index.md I should add to that folder.

For the homepage, I simply created an _index.md based on a different page I had. A simple copy and paste.

For the /blog/ folder, since I want the blog to automatically visualise according to the theme, I don’t know what to put in _index.md.

I don’t think you need a _index.md file in your content/blog folder—I don’t in mine. Just put the markdown files of the blog posts in that folder.

1 Like

Looks like a step in the right direction, but that only shows the basic list page of all the posts.

It doesn’t show the nicely formatted blog page that comes with the theme.

I am a little desperate because I can only publish when this is resolved. :frowning:

I am willing to pay whoever can spare a few minutes to look into this and help me resolve it.

Wow I found the solution by randomly hacking it.

The original theme has an index.html in /themes/CodeIT/layouts/. This produces a nice blog page in the homepage.

I modified index.html to suit what I need and moved it to /layouts/ to override the theme’s original. Then wrote my content for the homepage in /content/_index.md.

Now, I had lost the theme’s blog page. I wanted the theme’s blog page to be visualised in mydomain.com/blog/. This is how I achieved it. I don’t know how clean this hack is, but it works.

I copied the original index.html from /themes/CodeIT/layouts/, renamed it to blog.html, created the folder /layouts/blog/, and put blog.html in this folder.

Then I created the folder /content/blog/ and put an empty page in there. It doesn’t seem to matter what you name that page, I named it blog.md but it could be hello-world.md. This does the trick. (Just don’t name it index.md.)

Now when I open the domain I can see my personalised page, and if I click on “Blog” from the menu it visualises the theme’s blog layout with all the posts.

I didn’t need to move the posts from /posts/ to /blog/, everything is still in /posts/ as intended. This allows my visitors to access the page mydomain.com/posts/ in order to see the simple list page with all the posts in chronological order.

Please let me know if you have a better solution. :slight_smile:

Thanks for the help!

That’s not a hack, it’s the proper way to do it :wink: That’s why the theme is in a subfolder. Everything you mirror in your root layouts directory will override (modify) the theme files in the same location under themes/themename/layouts.

1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.