Pages and URLs
Cow turns the files and folders in your site into URLs. This guide shows you which files become pages, which files stay private, and where browser assets go.
| File | URL |
|---|---|
index.cow | / |
about.cow | /about |
blog/index.cow | /blog/ |
Public page URLs do not include the extension. You do not register a route for each file.
Keep files private
Names that begin with an underscore are private over HTTP. Use them for helpers, includes, and private directories. A request for a private file, such as
/_greetings, gets a 404 response.index.cow
about.cow
_greetings.cow
_partials/
header.cow
assets/
site.css
site.jsWarning: Importing a file does not, by itself, make its path private. Cow treats a helper without the underscore, such as
greetings.cow, as a page, and visitors can request its URL.Cow also does not serve dotfiles,
node_modules, or ordinary server-side JavaScript and TypeScript modules as public files.Serve browser assets
Put browser JavaScript and public JSON inside
assets/. CSS, images, and fonts can also live there.Warning: Treat everything in
assets/ as intentionally public. Keep secrets, server modules, and databases elsewhere.Use the request
To read a value from the query string, call
req.get(name). Save this as hello.cow:<?js
const name = req.get('name') || 'world'
?>
<p>Hello, <?= h(name) ?>.</p><p>Hello, Clover.</p>Query values come from the request URL. To handle a form submission, use the request method and the form APIs rather than adding another route file.