There is a similar problem entry here: An exception has been thrown during the rendering of a template - #3 by kevin but it’s not really answered, as I would like to update/downgrade to the working version of PHP if possible and if it’s the issue.
I am mainly confused because it was working just normal while I was experimenting with templates & customization and in one try it showed this. When I enable the parent theme in system.yaml it shows normal though, doesn’t show this problem.
I troubleshooted by creating another child theme and trying to load, then it worked fine, my custom homepage template was showing up. Then I tried putting a path to a folder in a title (link) and it showed me an error of cache as well “unable to write in cache directory”, this time pointing me to a specific one in grav-admin/cache/twig/ac. I went into that folder and just saw my custom template cached. Did not know what to do in there, honestly.
I found this clue online:
PHP Version Conflicts
Recently we have found an issue resulting in this error message: An exception has been thrown during the rendering of a template ("Trying to access array offset on value of type null"). This issue seems to stem from PHP7.4. The quick fix is to downgrade to version 7.3 or update to PHP8. We have had success with both workarounds and have Production Sites Running in both environments successfully.
But again, I did not update anything while I was customizing. I did update the whole system (sudo pacman -Suy) yesterday though. Could it be the problem? That PHP updates are conflicting and I need to downgrade them?
I troubleshooted by creating another child theme and trying to load, then it worked fine, my custom homepage template was showing up. Then I tried putting a path to a folder in a title (link) and it showed me an error of cache as well “unable to write in cache directory”
It seems that “Then I tried putting a path to a folder in a title (link)”, is causing the issue, but unfortunately, you don’t explain what you’ve done. The description is also rather cryptic.
Please create clear step-by-step instructions to reproduces the issue.
However, I cannot imagine it is related to the issue in this post. The underlying reasons why the template cannot be rendered are totally different: “Trying to access array offset on value of type null” versus “Unable to write to the cache directory” in this post.
Create a new child-theme using the CLI method. Set to inherit from Future2021.
In the new child-theme (future2021-child-theme) I copied the same folder structure that pmoreno kindly provided here.
In assets>css>custom.css I added my custom css for the index.html.twig template, that I want to be rendered for the home page.
Activated the future2021-child-theme in system.yaml.
The home page has a “index.md” file with some dummy content. In the grav admin GUI is also set for template:index.
Loaded and the above error was shown for the home page.
Loaded another page (ex: localhost:8000/blog) and the page was showing normally correct.
Changed templates from future2021-child-theme to future2021 (parent) and the home page shows normal with the dummy text.
→ My conclusion: the problem is in the caching of the index.html.twig of my future2021-child-theme
I stop doing things and come to comment it in here.
In another question I posted, @pamtbaau & pmoreno helped me to render both my custom html and css. I had followed the above process and the index page would show just fine.
It was the other day that the above errors started showing up. I wanted to repeat the whole process of the above mentioned comment of pamtbaau & pmoreno to have it as clear as possible. Then the following things happened:
First, the error was to have a blank page for my home page AND the same kind of cache error when trying to load another page such as localhost:8000/blog. I had done the process stated above but I thought that perhaps I had missed something.
So, second, I decided to repeat again the process from 0. Then my index page showed normal.
This is when when I wanted to link the titles of the main page to my other pages (because even though is a custom index page, I want it to be linked to the other pages, so if in index I have a part for blogs, I want it to go to the localhost:8000/blog, following the folder path). In my last comment is this part:
My idea of linking the index page to the ‘wharever’ page started off very primitive, like this: <h1><a href="../../../pages/06.wharever/">wharever</a></h1> . My goal was to "now, let me link each of the titles in my custom template to the actual pages where I have the content (these pages are all following the original future2021 templates). Please, note that perhaps I am doing stuff completely wrong in the linking, this was going to be the learning curve for my day: to learn to template html correctly so that the contents get sourced as if it was another template and not just a chunk of html.
The problem I faced in this part is that the crikey error showed up with the cache error. It was not very related to my “first linking try” in my humble knowledge of things. I was expecting an error related to a twig templating mistake in my syntax or similar…
When researching this cache error is when what I was reading online lead me to think it might be a PHP version error. Sorry I gave it so uncontextualized.
In any case, today I gave it another shoot from 0, as described above, and I got stuck with the cache error. Today no blank page shows up. I don’t know why the blank page was showing, can’t reproduce/remember what’s wrong thing I did in that try… sorry
Sorry for taking some days to answer, I decided to do it once on holidays because I can devote better hours of the day to think on this (instead of night hours…).