「ページが見つかりません」ページのカスタマイズ

Hi community!

I am trying to customize the “Page doesn’t exist” page. It currently shows the words " Oops! That page doesn’t exist or is private.". However, I would like to replace this with an image instead. Is there any way to do this? I was thinking of using plugin-outlets but there does not seem to be one for it. Thanks in advance.

「いいね!」 4

Maybe we should have a plugin outlet for this @eviltrout?

「いいね!」 4

Unfortunately it’s not simple since there are two versions of that page. One is generated server side and one is generated client side, depending on the error. We could add an outlet to the client side page but you wouldn’t always see it. Also I should note that page is used for all exceptions so you’d have to differentiate between a network error, a 500 error, a 404, etc.

「いいね!」 4

確認したかったのですが、これに対する解決策はすでに見つかったでしょうか?可能であれば、そのページも変更したいと考えております。

変更はありません、申し訳ありません。

「いいね!」 1

もちろん、理解しました。迅速な返信ありがとうございます。

JavaScriptでメッセージをカスタマイズできました。

window.addEventListener("DOMContentLoaded", function(){
    document.querySelector('.page-not-found .title').innerHTML = "ここに新しいメッセージ";
});

このスクリプトは、「おっと!そのページは存在しないか、プライベートです」というテキストが表示されているHTMLを置き換えます。試していませんが、理論的にはHTMLを追加して画像を表示することもできるはずです。

「いいね!」 2