The public folder

Files in a folder named public, at the root of the project, are served at the root of your site, unchanged: /public/robots.txt answers at /robots.txt. This works the same in the preview and on the published site.

On this page

Ask the agent

Add a robots.txt to the public folder that lets search engines crawl the whole site.

It writes the file in /public; publish again to put it online.

How paths map

#
File in the project Address on the site
/public/favicon.ico /favicon.ico
/public/robots.txt /robots.txt
/public/images/logo.png /images/logo.png

Write the address without /public. To get it, right-click the file in the file list and choose Copy Path: it copies /images/logo.png, not /public/images/logo.png.

What to put there

#
Put in public Keep out of public
favicon.ico, robots.txt, sitemap.xml, manifest.json, a service worker Scripts and styles your pages use: link or import them, so the bundler builds them
Downloads, like a PDF Images you import in your code: an import bundles the file wherever it is
Files your code loads with fetch() at run time, like a .json file or a .wasm file
Files another service expects at a fixed address

How the bundler treats these paths

#
Where the path is What happens
In HTML, like <img src="/images/logo.png"> The bundler leaves it as it is, and the site serves the file from public
In CSS, like url("/images/bg.webp") The bundler finds the file in public and includes it in the build
In code, like fetch('/data.json') The request goes to the site, which serves /public/data.json

Limits

#
  • Publish again after you add or change a file: the published site has the files of your last publish.
  • A published static site has a size limit for each file: see Bandwidth and limits.
  • Files you upload, like images, count toward the upload storage of the project's owner: see Plans.
  • This page is about static sites. A Cloud app is built by its own tools: see Browser and Cloud projects.