Templating doesn't work in production with apache

Hi, thanks for your help in advance.
We have a problem with displaying the twig based templating on a production server that runs Apache with the following error:

On local the code works fine using Laravel Valet.

We think the problem is related with twig, because when we add a default.php page, the default.php gets rendered properly. It’s also strange that this message appears only when we want to access the root / of our website although we specified a custom front page for that 'home' => 'start' in the config file (and therefore kirby should render start.twig and not default.php?).
On the other pages it returns 500 Internal server error.

Can you help us with this?

welcome to the forum. :tada:

setting the home option in the config will tell kirby to load the page with that name in from content folder. it does not refer to the name of the template but the folder name. please list the files in /content/start and tell us which /site/templates file you intend to use for the homepage.

1 Like

A default template always has to exist, even if it is never used, because it is a fallback template.

And yes, if the /start page has content file name start.txt, then start.twig should be used. I assume all your template and content file names are lowercase, so we can rule out such issues?

What about this 500 er error, is rewriting enabled on the server?

1 Like

Thanks for your quick reply. You are both right and I configured my site properly and also in the way you described in your posts - it also works with Laravel Valet on Mac just fine (everything gets rendered properly) but not on Apache on the server. (calling /index.php returns error above, all other pages or paths give 500 server error)

We use the mfgagency_kirby-twig plugin and switched all our templates to twig, we do not have a single php template in our template folder left. Could this be a problem?
We have a default.twig in place.

mod_rewrite is enabled on the server and the RewriteEngine is on. We did not modify the htaccess that comes with kirby 3.

My bet is on nginx vs apache because nginx runs in Laravel Valet which runs fine on local and the apache on the server don’t want to handle the site.

We also tried to run the site on a normal XAMPP on local with the same error, therefore my bet on this. Do you know what can be wrong?

Can you help me based on the information above?

I also use Laravel Valet locally and usually have no problem when deploying on a remote Apache server, provided I deploy the .htaccess that is useless for Valet.

But I admit I have no experience whatsoever with the Twig plugin and what templates are needed or not.

Not really on-topic, but I always find it daring to use a different server setup in development vs the production environment. Imho it’s always a better idea to replicate production in dev as much as you can. See e.g. Apache vs Nginx in production/development?

1 Like

In theory I agree, in practice I don’t think it’s an issue as long as you test Kirby and your results on the target server or something that closely resembles the target server right from the beginning from time to time and not just when you are about to deploy and in a rush.

Hey folks! I fixed my problem! We could finally get rid of the 500 errors and log into the panel. In the panel we recognized that some plugin functionality wasn’t working. We therefore checked our plugin folder and it was gone!

This was caused by our GitLab CI Pipeline (runs a Docker image) which can’t write files to the site/plugin directory on composer install. Fixing that created the plugin folder properly and everything is working quite well! Really, thank you for your time and your thoughts!