v2-hub icon indicating copy to clipboard operation
v2-hub copied to clipboard

Trigger a 404 asnwer with {{ 404 }}

Open tiagofcp opened this issue 5 years ago • 5 comments

Describe the bug Tried to generate a 404 with tag {{ 404}} page when a user visits a unpublished page

To Reproduce apply the {{ 404 }} on your layout

Expected behavior Show a 404 page with the actual url

Screenshots Screenshot 2020-02-03 at 16 18 39

Environment details (please complete the following information):

  • Statamic Version 2.11.18
  • Fresh Install:
  • OS: macOS
  • Web Server: Nginx, Valet
  • PHP Version: 7.3

tiagofcp avatar Feb 03 '20 16:02 tiagofcp

Interesting that no one has run into this before.

However you shouldn't need to manually add a tag. Unpublished pages should 404 automatically. Are you logged into the Control Panel? Drafts are accessible on the front-end while logged in.

Without the {{ 404 }}, does the draft URL 404 when you use an Incognito browser window?

jasonvarga avatar Feb 03 '20 21:02 jasonvarga

yes its rendering the pages when they are in draft, any one with the URL can access them, and since they appear on the sitemap google is indexing them

tiagofcp avatar Feb 03 '20 23:02 tiagofcp

But are they being rendered when you visit in a private browser window?

jasonvarga avatar Feb 03 '20 23:02 jasonvarga

ok without session opened its giving a 404, but they still appear on the sitemap but its a issue with advarkSEO, because if we disable the main language they disapear from all sitemaps

tiagofcp avatar Feb 04 '20 00:02 tiagofcp

We get this error as well. However it affects posts that are published with a future date and not drafts.

We would want to publish to a future date, so we check in the template if the date of the post is in the future and if so return the 404-tag - then we get this error.

Drafts doesn't really solve this since they would have to be manually published.

kyotoprotokollet avatar Jul 14 '20 09:07 kyotoprotokollet