Search code examples
htmlgithubnetlify

From where can I access my netlify.toml file?


So I have a couple of files in a GitHub repository, and I want to set up a custom 404 Error page. When I searched it up, It asked me to insert something in my netlify.toml file, which was supposed to be in my root directory(I think that means the repository itself), but I cannot find it! Am I supposed to create the file in my repository? Any help would be greatly appreciated.


Solution

  • The netlify.toml file is how Netlify handles file-based configuration, which lets you configure more advanced options for your deploys, as well as override options which you can otherwise set in the web-based frontend. If your repository doesn't already have this file, you can create it at the root of your repository and Netlify will read it automatically on the next deploy.

    While you can't set up redirect rules from the frontend, you don't necessarily need to create a netlify.toml file to use a custom 404 error page, though doing so gives you more advanced control. You can also create a _redirects file in the publish directory (ie: the directory that actually gets published by Netlify) with the original destination (including a splat * that matches anything after it, if desired), the redirected destination and an HTTP status code.

    # Put this in _redirects in your publish directory
    # This shows a custom 404 page for any paths on the site
    /* /404.html 404