跳转到内容

将你的 Astro 网站部署到 Heroku

Heroku 是一个平台即服务(PaaS),用于在云中构建、运行和管理现代应用程序。你可以使用本指南将 Astro 网站部署到 Heroku。

  1. 安装 Heroku CLI

  2. 通过注册创建一个 Heroku 帐户。

  3. 运行 heroku login 并填写你的 Heroku 凭据

    终端窗口
    $ heroku login
  4. 在你的项目根目录中创建一个名为 static.json 的文件,并包含以下内容

    static.json
    {
    "root": "./dist"
    }

    这是你网站的配置;请在 heroku-buildpack-static 阅读更多信息。

  5. 设置你的 Heroku git 远程仓库

    终端窗口
    # version change
    $ git init
    $ git add .
    $ git commit -m "My site ready for deployment."
    # creates a new app with a specified name
    $ heroku apps:create example
    # set buildpack for static sites
    $ heroku buildpacks:set https://github.com/heroku/heroku-buildpack-static.git
  6. 部署你的网站

    终端窗口
    # publish site
    $ git push heroku master
    # opens a browser to view the Dashboard version of Heroku CI
    $ heroku open

更多部署指南

贡献 社区 赞助