AboutProjectsResearchBlogContact
← Back to lists
Engineering

Quartz로 블로그 만들기

#quartz#productivity

이 블로그는 Quartz 4로 제작되었습니다. Quartz는 Obsidian으로 작성한 노트를 정적 웹사이트로 퍼블리싱할 수 있는 도구로 자유로운 커스텀이 가능하므로 설정하면서 얻은 지식과 경험들을 기록하고 공유하고자 합니다.

주요 기능

시작하는 법

  1. 'Quartz' 템플릿 저장소를 클론합니다.
  2. github에 'username.github.io'로 repo를 설정합니다.
  3. 'Pages'를 활성화 > 'Github Actions'로 변경합니다.
  4. content/ 폴더에 마크다운 파일을 추가합니다.
  5. npx quartz build --serve로 로컬에서 확인합니다.

1. 설치 과정

1) Git Repo 복제

git clone https://github.com/username/username.github.io
cd 저장소이름

2) 패키지 설치

npm install

3) Quartz 초기화

npx create quartz

프롬프트에서 아래 옵션을 선택합니다.

┌   Quartz v4.5.2 
│  ◆ Choose how to initialize the content in `/Users/Dev/quartz/content`
│  ● Empty Quartz 선택
│  ○ Copy an existing folder
│  ○ Symlink an existing folder
└
┌   
│ ◆ Choose how Quartz should resolve links in your content. This should match │ Obsidian's link format. You can change
│ this later in `quartz.config.ts`.
│ ● Treat links as shortest path ((default))
│ ○ Treat links as absolute path
│ ○ Treat links as relative paths
└

2. Git Config 설정 변경

1) Git Config 설정 변경

git config --global user.name "본인 아이디"
git config --global user.email "본인 이메일"

username 부분을 자신의 GitHub 아이디로 교체합니다.

2) GitHub Pages 활성화 및 Workflow 추가

[File : quartz/.github/workflows/deploy.yml]

name: Deploy Quartz site to GitHub Pages
on:
  push:
    branches:
      - main
  workflow_dispatch:
permissions:
  contents: read
  pages: write
  id-token: write
concurrency:
  group: "pages"
  cancel-in-progress: false
jobs:
  build:
    runs-on: ubuntu-22.04
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0
      - uses: actions/setup-node@v4
        with:
          node-version: 22
      - name: Install Dependencies
        run: npm ci
      - name: Build Quartz
        run: npx quartz build
      - name: Upload artifact
        uses: actions/upload-pages-artifact@v3
        with:
          path: public

  deploy:
    needs: build
    environment:
      name: github-pages
      url: ${{ steps.deployment.outputs.page_url }}
    runs-on: ubuntu-22.04
    steps:
      - name: Deploy to GitHub Pages
        id: deployment
        uses: actions/deploy-pages@v4

3. 빌드 및 배포

1) 로컬 미리보기

npx quartz build --serve

확인방법 : 브라우저 접속 후 http://localhost:8080 에서 생성된 사이트를 확인할 수 있습니다.

2) GitHub 배포

git add .github/workflows/deploy.yml
git commit -m "fix: yaml indentation in deploy workflow"
git push origin main

확인방법 : 배포 완료 시 'username.github.io'로 잘 접속되는 것을 알 수 있다.


참고자료 Quartz 4 세팅 관련 참고한 자료 목록입니다.

원문 보기 ↗