This is a bare-bones Astro project that has everything you need to quickly deploy it to Netlify.
Hate reading, here's a video: https://youtu.be/SknFflQVOys!
Love reading, here's blog post: www.netlify.app/blog/deploy-your-astro-project-fast/!
- Quick Setup + Deploy Option
- Regular Setup
- Astro + Netlify Resources
- Project Structure
- Commands
- Testing
- Want to learn more?
Click this button and it will help you create a new repo, create a new Netlify project, and deploy!
-
Clone this repo with one of these options:
- Click the 'Use this template' button at the top of the page
- Or via the command line
git clone https://github.com/netlify-templates/astro-quickstart
-
Then install the necessary packages and run the project locally to make sure everything works.
npm install npm run dev
Alternatively, you can run this locally with the Netlify CLI's by running the
netlify dev
command for more options like receiving a live preview to share (netlify dev --live
) and the ability to test Netlify Functions and redirects.
-
Install the Netlify CLI globally
npm install netlify-cli -g
-
Run
npm run build
-
Then use the
netlify deploy
for a deploy preview link ornetlify deploy --prod
to deploy to production
Here are a few other ways you can deploy this template:
-
Use the Netlify CLI's create from template command
netlify sites:create-template astro-quickstart
which will create a repo, Netlify project, and deploy it -
If you want to utilize continuous deployment through GitHub webhooks, run the Netlify command
netlify init
to create a new project based on your repo ornetlify link
to connect your repo to an existing project
Here are some resources to help you on your Astro + Netlify coding fun!
Hope this template helps :) Happy coding π©π»βπ»!
Inside of your Astro project, you'll see the following folders and files:
/
βββ public/
β βββ favicon.ico
βββ src/
β βββ components/
β β βββ Layout.astro
β βββ pages/
β βββ index.astro
βββ package.json
Astro looks for .astro
or .md
files in the src/pages/
directory. Each page is exposed as a route based on its file name.
There's nothing special about src/components/
, but that's where we like to put any Astro/React/Vue/Svelte/Preact components or layouts.
Any static assets, like images, can be placed in the public/
directory.
All commands are run from the root of the project, from a terminal:
Command | Action |
---|---|
npm install |
Installs dependencies |
npm run dev |
Starts local dev server at localhost:3000 |
npm run build |
Build your production site to ./dist/ |
npm run preview |
Preview your build locally, before deploying |
Weβve included some tooling that helps us maintain these templates. This template currently uses:
- Renovate - to regularly update our dependencies
- Cypress - to run tests against how the template runs in the browser
- Cypress Netlify Build Plugin - to run our tests during our build process
If your team is not interested in this tooling, you can remove them with ease!
In order to keep our project up-to-date with dependencies we use a tool called Renovate. If youβre not interested in this tooling, delete the renovate.json
file and commit that onto your main branch.
For our testing, we use Cypress for end-to-end testing. This makes sure that we can validate that our templates are rendering and displaying as weβd expect. By default, we have Cypress not generate deploy links if our tests donβt pass. If youβd like to keep Cypress and still generate the deploy links, go into your netlify.toml
and delete the plugin configuration lines:
[[plugins]]
package = "netlify-plugin-cypress"
- [plugins.inputs.postBuild]
- enable = true
-
- [plugins.inputs]
- enable = false
If youβd like to remove the netlify-plugin-cypress
build plugin entirely, youβd need to delete the entire block above instead. And then make sure sure to remove the package from the dependencies using:
npm uninstall -D netlify-plugin-cypress
And lastly if youβd like to remove Cypress entirely, delete the entire cypress
folder and the cypress.config.ts
file. Then remove the dependency using:
npm uninstall cypress
Feel free to check our documentation or jump into our Discord server.