1

Following the Minjingo CraftQuest tutorial, I am getting an error on the front end when I access any routes other than the root/home page.

In my template folder, I have a structure that looks like:

templates/
├── index.twig
├── about/
│   └── _entry.twig
├── drinks/
│   └── _entry.twig
└── news/
    └── _entry.twig

In my about section settings, my template is about/_entry, as it is in the tutorial.

The error I get is:

HTTP 404 – Not Found – yii\web\NotFoundHttpException
Template not found: about

Maybe I missed a step? What should I look for?

1

Templates or folder with an underscore are private and can't be accessed via template routing. Remove the _ and you are fine. For example news/entry instead of news/_entry

| improve this answer | |
  • Then why is _entry used in the tutorial? – BBaysinger Mar 13 '19 at 20:43
  • Usually because those templates are not meant to be exposed to public routing. I usually never create public templates and keep all of them private – Robin Schambach Mar 13 '19 at 20:44
  • In the tutorial, those are public pages... I'm not understanding why it works there, but not for me. – BBaysinger Mar 13 '19 at 20:46
  • Im sure they are not public. Otherwise they would not contain an underscore. Especially for seo purposes it makes no sense to have an url news/_entry those routes are usually only meant to be accessed via entry routes – Robin Schambach Mar 13 '19 at 20:47
  • In the tutorial, the route to the about page is just about/, and in the templates folder, the file is about/_entry.twig... Are you saying I should do it differently than the tutorial? – BBaysinger Mar 13 '19 at 20:49
1

I haven't seen the video but just reading you I think that he may be using a layout file in the tutorial and use the _templates as includes. So inside a master template:

{% include "about/_entry" %}

Or... if you have index.twig with:

<!doctype html>
<html lang="en">
<head>
    ...
</head>
<body>
    <h1>Your site</h1>
    {% block content %}
        <p>You shouldn't see me</p>
    {% endblock %}
</body>
</html>

And about/_entry.twig with:

{% block content %}
    Hello or {{entry.title}} if you have content in there
{% endblock %}

That would work also... I may also be reading you completely wrong :)

| improve this answer | |
0

I problem was that I missed the part where the slug for the About Craft Coffee entry was changed. In video 26, Creating a Structure Section, at 2:58, the slug about-crafty-coffee was changed to just about. He did it real quick, and I had to go back and watch the whole video to notice that. I should have rewatched it sooner. So that's why my element routing was not working; there wasn't an entry that matched the slug, because I hadn't changed mine.

| improve this answer | |

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.