statamic / v2-hub

Statamic 2 - Feature Requests and Bug Reports
https://statamic.com
95 stars 5 forks source link

Trigger a 404 asnwer with {{ 404 }} #2489

Open tiagofcp opened 4 years ago

tiagofcp commented 4 years ago

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):

jasonvarga commented 4 years ago

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?

tiagofcp commented 4 years ago

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

jasonvarga commented 4 years ago

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

tiagofcp commented 4 years ago

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

kyotoprotokollet commented 4 years ago

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.