1

Very new to craft CMS, recently just installed XAMPP with php 7 and craft 3 and followed the getting started tutorial from Craft CMS. Then when I try to preview or open the page created from the tutorial, it gives me a 404 template not found error.

The error is as follows:

yii\web\NotFoundHttpException: Template not found: $PRIMARY_SITE_URL/$PRIMARY_SITE_URL/blog/this-is-my-blog in C:\xampp\htdocs\craft\vendor\craftcms\cms\src\controllers\TemplatesController.php:92
Stack trace:
#0 [internal function]: craft\controllers\TemplatesController->actionRender('$PRIMARY_SITE_U...', Array)
#1 C:\xampp\htdocs\craft\vendor\yiisoft\yii2\base\InlineAction.php(57): call_user_func_array(Array, Array)
#2 C:\xampp\htdocs\craft\vendor\yiisoft\yii2\base\Controller.php(181): yii\base\InlineAction->runWithParams(Array)
#3 C:\xampp\htdocs\craft\vendor\craftcms\cms\src\web\Controller.php(190): yii\base\Controller->runAction('render', Array)
#4 C:\xampp\htdocs\craft\vendor\yiisoft\yii2\base\Module.php(534): craft\web\Controller->runAction('render', Array)
#5 C:\xampp\htdocs\craft\vendor\craftcms\cms\src\web\Application.php(274): yii\base\Module->runAction('templates/rende...', Array)
#6 C:\xampp\htdocs\craft\vendor\yiisoft\yii2\web\Application.php(104): craft\web\Application->runAction('templates/rende...', Array)
#7 C:\xampp\htdocs\craft\vendor\craftcms\cms\src\web\Application.php(259): yii\web\Application->handleRequest(Object(craft\web\Request))
#8 C:\xampp\htdocs\craft\vendor\yiisoft\yii2\base\Application.php(392): craft\web\Application->handleRequest(Object(craft\web\Request))
#9 C:\xampp\htdocs\craft\web\index.php(23): yii\base\Application->run()
#10 {main}

and it looks like this: enter image description here

I have followed all the instructions in the tutorial, and have created the _entry.twig in my templates/blog folder. Any help would be much appreciated

3
  • Do you have a PRIMARY_SITE_URL key in your .env file? For example, your .env file might have PRIMARY_SITE_URL="http://example.test"
    – ajamesm
    Feb 25 at 2:15
  • @ajamesm No, it doesn't seem like I have it in my .env file. How do I add this in if I am running on localhost at the moment? would it just be PRIMARY_SITE_URL=localhost? Feb 26 at 2:04
  • OH WAIT, i put PRIMARY_SITE_URL="localhost/craft/web" and it worked! Thank you so much. I couldn't find any documentations on PRIMARY_SITE_URL, where was I supposed to add this key in? Feb 26 at 3:42
1

You have to go to your Admin Dashboard > Settings > Sites > Your site and delete Base URL field, then save it and try to navigate.

enter image description here

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.