Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Serve noindex homepage copy at /-/ #2393

Closed
simonw opened this issue Aug 15, 2024 · 4 comments
Closed

Serve noindex homepage copy at /-/ #2393

simonw opened this issue Aug 15, 2024 · 4 comments

Comments

@simonw
Copy link
Owner

simonw commented Aug 15, 2024

Sites like https://datasette.io/ and https://til.simonwillison.net/ run Datasette but with a custom template for the homepage. This makes them a little harder to use because there’s nowhere to go for the list of databases (I use /-/databases for that sometimes but it’s not very pretty).

Solution: serve a copy of the homepage at /-/ but put a <meta name="robots" content="noindex"> on it to avoid it being accidentally indexed as duplicate content.

I’ll have /- redirect to /-/ too.

@simonw
Copy link
Owner Author

simonw commented Aug 15, 2024

Documentation can go here: https://docs.datasette.io/en/latest/pages.html#top-level-index

@simonw
Copy link
Owner Author

simonw commented Aug 15, 2024

I just realized that dropping a index.html page in to customize / will also affect /-/ unless I do something special to ensure only the base template is used there.

@simonw simonw closed this as completed in 9306766 Aug 15, 2024
@simonw
Copy link
Owner Author

simonw commented Aug 15, 2024

Docs are now live here: https://docs.datasette.io/en/latest/pages.html#top-level-index

The index page can also be accessed at /-/, useful for if the default index page has been replaced using an index.html custom template. The /-/ page will always render the default Datasette index.html template.

@simonw
Copy link
Owner Author

simonw commented Aug 15, 2024

alternative_homepage = request.path == "/-/"
return await self.render(
["default:index.html" if alternative_homepage else "index.html"],

There's an edge-case here: if the user has Datasette running at an alternative prefix using base_url I don't think this will work. I'll fix that if anyone ever complains about it!

@simonw simonw mentioned this issue Aug 15, 2024
3 tasks
simonw added a commit that referenced this issue Aug 16, 2024
simonw added a commit that referenced this issue Aug 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant