I have a little problem and are hopping that someone can help me.
From time to time my Layout get’s broken. The cause for this is, that the site loads the error message for unfound sites and attaches the in-document-style of the error message into my site document.
When I look at the code source in the browser i get this:
<html>
// my normal site code
</html>
<html>
// error message with in-document style
</html>
Weird is, that the error message is not actually displayed, but It seems like Kirby is looking for something. So maybe it’s because of how I implemented my navigation. This is an example of one navigation button. The layout requires the buttons to be single elements rather than a list.
Appologies if my description wasn’t clear enough. I have a link below. But it’s tricky, because the bug only appears from time to time. So it’s likely that you don’t see it at all.
Normaly all text are aligned to the left. If the texts are centered, then you see the bug. If you then check out the source code in the browser, you will find an error message at the end causing this behavior.
My guess is, that it has something to do with the way I do my navigation. Do you see problem in this? (Example below)
If the error is caused by Kirby not finding the page, then @anon77445132’s suggestion is certainly a good way to prevent that error. That way, you make sure that the page exists before trying to call a method on it. It would make sense to repeat that for every page.
Like you anticipated, I could not reproduce the issue. Maybe it is caused during upload of a new website version when not all pages were transferred?
Edit: if it happens again, check your php error logs. Maybe you can get some more information regarding the error from there.
Thanks everyone for your help! I will try @anon77445132’s suggestions, this makes sense.
The source code from the error looks like this: (It appears right under my regular code)
<!DOCTYPE html>
<html lang="en">
<head>
<title>Error</title>
<style>
body {
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
padding: 10%;
text-align: center;
line-height: 1.5em;
}
a {
color: inherit;
}
a:hover,
a:focus {
color: #000;
}
p {
max-width: 30em;
margin: 0 auto;
}
.notice {
font-weight: bold;
}
.admin-advice {
font-size: .8em;
font-style: italic;
color: #999;
padding-top: 3rem;
}
</style>
</head>
<body>
<p class="notice">
This page is currently offline due to an unexpected error. We are very sorry for the inconvenience and will fix it as soon as possible.
</p>
<p class="admin-advice">
Advice for developers and administrators:<br>
Enable <a href="https://getkirby.com/docs/cheatsheet/options/debug">debug mode</a> to get further information about the error.
</p>
</body>
</html>
It seems like the error only appears while developing local (with MAMP).
I also did not see the error while the page is on the web, so maybe I can look over it?
It really seems like it was an local problem caused by MAMP, the website is now online & the bug never appeared again. I still implemented @anon77445132’s advice just to be safe.