{"database": "docs", "table": "sections", "is_view": false, "human_description_en": "where breadcrumbs contains \"Custom pages\" and page = \"custom_templates\"", "rows": [["custom_templates:custom-pages-404", "custom_templates", "custom-pages-404", "Returning 404s", "To indicate that content could not be found and display the default 404 page you can use the  raise_404(message)  function: \n                 {% if not rows %}\n    {{ raise_404(\"Content not found\") }}\n{% endif %} \n                 If you call  raise_404()  the other content in your template will be ignored.", "[\"Custom pages and templates\", \"Custom pages\"]", "[]"], ["custom_templates:custom-pages-headers", "custom_templates", "custom-pages-headers", "Custom headers and status codes", "Custom pages default to being served with a content-type of  text/html; charset=utf-8  and a  200  status code. You can change these by calling a custom function from within your template. \n                 For example, to serve a custom page with a  418 I'm a teapot  HTTP status code, create a file in  pages/teapot.html  containing the following: \n                 {{ custom_status(418) }}\n<html>\n<head><title>Teapot</title></head>\n<body>\nI'm a teapot\n</body>\n</html> \n                 To serve a custom HTTP header, add a  custom_header(name, value)  function call. For example: \n                 {{ custom_status(418) }}\n{{ custom_header(\"x-teapot\", \"I am\") }}\n<html>\n<head><title>Teapot</title></head>\n<body>\nI'm a teapot\n</body>\n</html> \n                 You can verify this is working using  curl  like this: \n                 $ curl -I 'http://127.0.0.1:8001/teapot'\nHTTP/1.1 418\ndate: Sun, 26 Apr 2020 18:38:30 GMT\nserver: uvicorn\nx-teapot: I am\ncontent-type: text/html; charset=utf-8", "[\"Custom pages and templates\", \"Custom pages\"]", "[]"], ["custom_templates:custom-pages-parameters", "custom_templates", "custom-pages-parameters", "Path parameters for pages", "You can define custom pages that match multiple paths by creating files with  {variable}  definitions in their filenames. \n                 For example, to capture any request to a URL matching  /about/* , you would create a template in the following location: \n                 templates/pages/about/{slug}.html \n                 A hit to  /about/news  would render that template and pass in a variable called  slug  with a value of  \"news\" . \n                 If you use this mechanism don't forget to return a 404 if the referenced content could not be found. You can do this using  {{ raise_404() }}  described below. \n                 Templates defined using custom page routes work particularly well with the  sql()  template function from  datasette-template-sql  or the  graphql()  template function from  datasette-graphql .", "[\"Custom pages and templates\", \"Custom pages\"]", "[{\"href\": \"https://github.com/simonw/datasette-template-sql\", \"label\": \"datasette-template-sql\"}, {\"href\": \"https://github.com/simonw/datasette-graphql#the-graphql-template-function\", \"label\": \"datasette-graphql\"}]"], ["custom_templates:custom-pages-redirects", "custom_templates", "custom-pages-redirects", "Custom redirects", "You can use the  custom_redirect(location)  function to redirect users to another page, for example in a file called  pages/datasette.html : \n                 {{ custom_redirect(\"https://github.com/simonw/datasette\") }} \n                 Now requests to  http://localhost:8001/datasette  will result in a redirect. \n                 These redirects are served with a  302 Found  status code by default. You can send a  301 Moved Permanently  code by passing  301  as the second argument to the function: \n                 {{ custom_redirect(\"https://github.com/simonw/datasette\", 301) }}", "[\"Custom pages and templates\", \"Custom pages\"]", "[]"]], "truncated": false, "filtered_table_rows_count": 4, "expanded_columns": [], "expandable_columns": [], "columns": ["id", "page", "ref", "title", "content", "breadcrumbs", "references"], "primary_keys": ["id"], "units": {}, "query": {"sql": "select id, page, ref, title, content, breadcrumbs, [references] from sections where :p0 in (select value from json_each([sections].[breadcrumbs])) and \"page\" = :p1 order by id limit 101", "params": {"p0": "Custom pages", "p1": "custom_templates"}}, "facet_results": {}, "suggested_facets": [{"name": "references", "toggle_url": "https://stable-docs.datasette.io/docs/sections.json?breadcrumbs__arraycontains=Custom+pages&page=custom_templates&_facet=references"}, {"name": "breadcrumbs", "type": "array", "toggle_url": "https://stable-docs.datasette.io/docs/sections.json?breadcrumbs__arraycontains=Custom+pages&page=custom_templates&_facet_array=breadcrumbs"}], "next": null, "next_url": null, "private": false, "allow_execute_sql": true, "query_ms": 17.555149010149762}