1

The blog post should display the posts created but when I got to the slug /blog it says 404 not found as well as the press news should be displayed here /press-news but same thing happens.

If i access the posts directly : site.com/blog/blog-post-name it is displayed correctly.

an you help me giving me some probable causes so that i can check how to fix it? thanks

2

If blog is a channel and site.com/blog/blog-post-name is correctly displayed but you can't access site.com/blog, that is probably because you are missing an index.html template inside the blog folder.

Craft will do the route automatically if you add an index.html file inside a section folder. (rightly named)

Then, what you want is to display the blog related posts inside that template. From there, just make a simple Craft request and loop through the result.

Something like that should work:

{% for entry in craft.entries.section('blog').all %}
    <article>
        <h3><a href="{{ entry.url }}">{{ entry.title }}</a></h3>
    </article>
{% endfor %}

I invite you to read the official doc, all the basics (like that one) are well documented and a lot of examples are available.

You may also take a look at the Routing documentation to understand the step behind Craft routing.

2

If you've setup a channel, it does not include a "blog index" by default, for this you need to make it yourself by placing an index.twig file within the blog folder (If that is a directory in your templates folder).

Check the answer in this question for an example on how to do the twig code. What's the right way to create a simple blog in Craft?

  • Thanks 2 for providing this info. im gonna try the twig code. – Alejo_Blue Feb 6 at 19:55
  • that index.twig file, what should i include? what will be the content to put on it? thanks for the response. – Alejo_Blue Feb 6 at 20:22
  • thanks for your help, indeed it was very informative. – Alejo_Blue Feb 6 at 21:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.