···4455Quartz effectively turns your Markdown files and other resources into a bundle of HTML, JS, and CSS files (a website!).
6677-However, if you'd like to publish your site to the world, you need a way to host it online. This guide will detail how to deploy with either GitHub Pages or Cloudflare pages but any service that allows you to deploy static HTML should work as well (e.g. Netlify, Replit, etc.)
77+However, if you'd like to publish your site to the world, you need a way to host it online. This guide will detail how to deploy with common hosting providers but any service that allows you to deploy static HTML should work as well.
88+99+> [!warning]
1010+> The rest of this guide assumes that you've already created your own GitHub repository for Quartz. If you haven't already, [[setting up your GitHub repository|make sure you do so]].
811912> [!hint]
1013> Some Quartz features (like [[RSS Feed]] and sitemap generation) require `baseUrl` to be configured properly in your [[configuration]] to work properly. Make sure you set this before deploying!
···26292730To add a custom domain, check out [Cloudflare's documentation](https://developers.cloudflare.com/pages/platform/custom-domains/).
28312929-## GitHub Pages
3030-3131-Like Quartz 3, you can deploy the site generated by Quartz 4 via GitHub Pages.
3232-3332> [!warning]
3434-> Quartz generates files in the format of `file.html` instead of `file/index.html` which means the trailing slashes for _non-folder paths_ are dropped. As GitHub pages does not do this redirect, this may cause existing links to your site that use trailing slashes to break. If not breaking existing links is important to you, consider using [[#Cloudflare Pages]].
3333+> Cloudflare Pages only allows shallow `git` clones so if you rely on `git` for timestamps, it is recommended you either add dates to your frontmatter (see [[authoring content#Syntax]]) or use another hosting provider.
3434+3535+## GitHub Pages
35363637In your local Quartz, create a new file `quartz/.github/workflows/deploy.yml`.
3738···9293> If you get an error about not being allowed to deploy to `github-pages` due to environment protection rules, make sure you remove any existing GitHub pages environments.
9394>
9495> You can do this by going to your Settings page on your GitHub fork and going to the Environments tab and pressing the trash icon. The GitHub action will recreate the environment for you correctly the next time you sync your Quartz.
9696+9797+> [!info]
9898+> Quartz generates files in the format of `file.html` instead of `file/index.html` which means the trailing slashes for _non-folder paths_ are dropped. As GitHub pages does not do this redirect, this may cause existing links to your site that use trailing slashes to break. If not breaking existing links is important to you (e.g. you are migrating from Quartz 3), consider using [[#Cloudflare Pages]].
959996100### Custom Domain
97101···1681725. Enter your subdomain into the field and press Add
169173170174## Netlify
171171-172172-Like Vercel, you can also deploy the site generated by Quartz 4 via Netlify.
1731751741761. Log in to the [Netlify dashboard](https://app.netlify.com/) and click "Add new site".
1751772. Select your Git provider and repository containing your Quartz project.
···180182181183## GitLab Pages
182184183183-You can configure GitLab CI to build and deploy a Quartz 4 project.
184184-185185In your local Quartz, create a new file `.gitlab-ci.yaml`.
186186187187```yaml title=".gitlab-ci.yaml"
···203203 - hash -r
204204 - npm ci
205205 script:
206206- - npx prettier --write .
207207- - npm run check
208206 - npx quartz build
209207 artifacts:
210208 paths:
···227225 - public
228226```
229227230230-When `.gitlab-ci.yaml` is commited, GitLab will build and deploy the website as a GitLab Page. You can find the url under `Deploy` -> `Pages` in the sidebar.
228228+When `.gitlab-ci.yaml` is commited, GitLab will build and deploy the website as a GitLab Page. You can find the url under `Deploy > Pages` in the sidebar.
231229232230By default, the page is private and only visible when logged in to a GitLab account with access to the repository but can be opened in the settings under `Deploy` -> `Pages`.
docs/images/github-init-repo-options.png
This is a binary file and will not be displayed.
docs/images/github-quick-setup.png
This is a binary file and will not be displayed.
+2-2
docs/index.md
···22title: Welcome to Quartz 4
33---
4455-Quartz is a fast, batteries-included static-site generator that transforms Markdown content into fully functional websites. Thousands of students, developers, and teachers are [[showcase|already using Quartz]] to publish personal notes, wikis, and [digital gardens](https://jzhao.xyz/posts/networked-thought) to the web.
55+Quartz is a fast, batteries-included static-site generator that transforms Markdown content into fully functional websites. Thousands of students, developers, and teachers are [[showcase|already using Quartz]] to publish personal notes, websites, and [digital gardens](https://jzhao.xyz/posts/networked-thought) to the web.
6677## 🪴 Get Started
88···19192020This will guide you through initializing your Quartz with content. Once you've done so, see how to:
21212222-1. [[authoring content|Author content]] in Quartz
2222+1. [[authoring content|Writing content]] in Quartz
23232. [[configuration|Configure]] Quartz's behaviour
24243. Change Quartz's [[layout]]
25254. [[build|Build and preview]] Quartz
+31
docs/setting up your GitHub repository.md
···11+---
22+title: Setting up your GitHub repository
33+---
44+55+First, make sure you have Quartz [[index#🪴 Get Started|cloned and setup locally]].
66+77+Then, create a new repository on GitHub.com. Do **not** initialize the new repository with `README`, license, or `gitignore` files.
88+99+![[github-init-repo-options.png]]
1010+1111+At the top of your repository on GitHub.com's Quick Setup page, click the clipboard to copy the remote repository URL.
1212+1313+![[github-quick-setup.png]]
1414+1515+In your terminal of choice, navigate to the root of your Quartz folder. Then, run the following command, replacing `REMOTE-URL` with the URL you just copied from the previous step.
1616+1717+```bash
1818+git remote add origin REMOTE-URL
1919+```
2020+2121+To verify that you set the remote URL correctly, run the following command.
2222+2323+```bash
2424+git remote -v
2525+```
2626+2727+Then, you can sync the content to upload it to your repository.
2828+2929+```bash
3030+npx quartz sync
3131+```
+5
quartz/cli/handlers.js
···196196 )
197197 await fs.promises.writeFile(configFilePath, configContent)
198198199199+ // setup remote
200200+ execSync(
201201+ `git remote show upstream || git remote add upstream https://github.com/jackyzha0/quartz.git`,
202202+ )
203203+199204 outro(`You're all set! Not sure what to do next? Try:
200205 • Customizing Quartz a bit more by editing \`quartz.config.ts\`
201206 • Running \`npx quartz build --serve\` to preview your Quartz locally