I'm learning how to use Craft. I've set it up locally using MAMP (regular) on OS X Yosemite (10.10.5). Everything is working fine until I start getting into Twig templates. When I try viewing files that contain twig code in any browser, the browser shows the twig code as content (for example, I see{% block main %} and {# comments #} within the window). I'm thinking this is a MAMP issue.

However, as I understand it, Craft itself uses Twig. If that's the case, then it wouldn't be a MAMP issue, since then both the Craft admin site and my files wouldn't work. Any hints as to where the problem lies would be greatly appreciated. Thanks!

Update: Trying to access it through MAMP Pro to see if that makes a difference. Now I'm being blocked right after the root. Here's a pic of the error (result with localhost in the URL not the file path): enter image description here

I don't know anything about Apache -- is it safe to display my entire httpd.conf code online to see if anyone knows it's a setting in that files that's causing the issue? I'm sorry -- this question/thread is all over the place.

  • 1
    Are you putting your Twig templates in the craft/templates folder?
    – Brad Bell
    Commented Sep 8, 2015 at 3:46
  • Yes. And in that folder, both _layout.html, 404.html and index.html show twig code. Commented Sep 8, 2015 at 5:21
  • Can you post a screenshot of your browser and what you're seeing? Commented Sep 9, 2015 at 20:38
  • Can you go back to regular MAMP and post a screenshot of when you're seeing twig code? Commented Sep 11, 2015 at 22:22

1 Answer 1


Are you opening those templates directly in the browser? When you do this, you are bypassing Craft and the browser does not know what to do with the Craft tags or how to access the database and will show the tags instead of the contents.

Since you have got the CP working, all should be good though. If you go to the CP and click on your bold site name at the top left in the nav, the default homepage (or yours) should get loaded. What you actually see there is the index.html loaded into the _layout.html and you should not get any twig template tags. If you go ahead now and add some made-up segment to the address in the address field of the browser /xyz e.g., you will see the 404.html loaded into _layout.html.

To see your templates like your visitors will see them, Craft needs to kick in. This will only happen, if you enter a pages complete url in the browser, not a template location on your disk. (If you opended the templates directly, your address will look somethin like file:///Applications/MAMP/htdocs… which will not work. Visible or not, your address should always begin with http:// …)

Have you still got the default news section in the install? You could add 2 or 3 dummy news in the CP, and then navigate to those news entries as described above. The template that gets used to display a single news is news/_entry.html but _entry.html will never be part of the url. It is used by Craft to fill in the contents and your urls will be somtheing like news/dummy-news1, news/dummy-news2. Hope that makes it a bit clearer?

  • I tried viewing the pages before (including the default news pages) through Craft and by typing "localhost:80...etc" into the browser, but received an error message: Forbidden - You don't have permission to access files on this server. I tried moving the Craft folder into the Public folder, and changing the path to look for it in the new location but still no luck. I've been looking on other threads, and it seems like I need to modify something in the Apache HTTP config file? Commented Sep 8, 2015 at 19:48
  • Hm, I don´t know. Today I am using MAMP Pro but I used MAMP before with other CMSes and never had to touch the HTTP config file. I would try to go back to a setting like htdocs/craft and htdocs/public or htdocs/my-project/craft and htdocs/my-project/public if you had all set up in a subfolder e.g. my-project. If you have modified the .htaccess file in public in the meantime undo the changes. (btw: Make sure the file is called .htaccess with a point before the „h“.) Commented Sep 8, 2015 at 21:35
  • If you can get into your CP again, deleting the admin/dashboard in the browser address field should then send you to your homepage. If this is not working, can you control that this address is nevertheless present in settings > general > site-url. If it is, you still have no luck and have everything in a subfolder like my-project, try and add that before the index.php to the .htaccess in the public folder. (The complete line then is RewriteRule (.+) my-project/index.php?p=$1 [QSA,L] PS. Thanks @Alec for the assistance with the first answer! Commented Sep 8, 2015 at 21:35
  • Hello, Thank you so much for taking the time to write these answers! I'm still having issues. Would this code in the httpd.conf file be what's blocking me? (I have apache 2.2). It seems other people have had success in changing some things in Apache files, but there are so many solutions shown for different versions I don't know which one will work. <Directory /> Options FollowSymLinks AllowOverride None Order deny,allow Deny from all </Directory> Commented Sep 11, 2015 at 19:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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