|
| 1 | +# Publishing a Static Site |
| 2 | + |
| 3 | +AS Notes includes a built-in HTML conversion tool that turns your markdown notes into a static website. You can use this to publish your knowledge base as a standalone site or deploy it to GitHub Pages. |
| 4 | + |
| 5 | +## How It Works |
| 6 | + |
| 7 | +The `html-conversion` package scans a folder of markdown files and converts them to HTML. [[Wikilinks]] between pages are automatically resolved to the correct HTML links. |
| 8 | + |
| 9 | +## Prerequisites |
| 10 | + |
| 11 | +- [Node.js](https://nodejs.org) 20 or later |
| 12 | +- Your notes in a folder of `.md` files |
| 13 | + |
| 14 | +## Standalone Usage |
| 15 | + |
| 16 | +### 1. Install the converter |
| 17 | + |
| 18 | +Clone or download the `html-conversion` package from the AS Notes repository, then install dependencies: |
| 19 | + |
| 20 | +```bash |
| 21 | +cd html-conversion |
| 22 | +npm install |
| 23 | +npm run build |
| 24 | +``` |
| 25 | + |
| 26 | +### 2. Convert your notes |
| 27 | + |
| 28 | +```bash |
| 29 | +npm run convert -- --input /path/to/your/notes --output /path/to/output |
| 30 | +``` |
| 31 | + |
| 32 | +The output folder will be wiped and regenerated on each run. Point any static file server at the output folder to preview the result. |
| 33 | + |
| 34 | +### Local preview |
| 35 | + |
| 36 | +You can serve the output locally using any static file server, for example: |
| 37 | + |
| 38 | +```bash |
| 39 | +npx serve /path/to/output |
| 40 | +``` |
| 41 | + |
| 42 | +## Publishing to GitHub Pages |
| 43 | + |
| 44 | +### 1. Add a CI workflow |
| 45 | + |
| 46 | +Create `.github/workflows/pages.yml` in your repository: |
| 47 | + |
| 48 | +```yaml |
| 49 | +name: Deploy to GitHub Pages |
| 50 | + |
| 51 | +on: |
| 52 | + push: |
| 53 | + branches: [main] |
| 54 | + |
| 55 | +jobs: |
| 56 | + deploy: |
| 57 | + runs-on: ubuntu-latest |
| 58 | + permissions: |
| 59 | + pages: write |
| 60 | + id-token: write |
| 61 | + environment: |
| 62 | + name: github-pages |
| 63 | + url: ${{ steps.deployment.outputs.page_url }} |
| 64 | + steps: |
| 65 | + - uses: actions/checkout@v4 |
| 66 | + - uses: actions/setup-node@v4 |
| 67 | + with: |
| 68 | + node-version: '20' |
| 69 | + - run: npm ci |
| 70 | + working-directory: html-conversion |
| 71 | + - run: npm run build |
| 72 | + working-directory: html-conversion |
| 73 | + - run: npm run convert -- --input ../notes --output ../site |
| 74 | + working-directory: html-conversion |
| 75 | + - uses: actions/upload-pages-artifact@v3 |
| 76 | + with: |
| 77 | + path: site |
| 78 | + - id: deployment |
| 79 | + uses: actions/deploy-pages@v4 |
| 80 | +``` |
| 81 | +
|
| 82 | +Adjust the `--input` path to match the folder containing your notes. |
| 83 | + |
| 84 | +### 2. Enable GitHub Pages |
| 85 | + |
| 86 | +In your repository go to **Settings → Pages** and set the source to **GitHub Actions**. |
| 87 | + |
| 88 | +### Custom Domain |
| 89 | + |
| 90 | +If you want to serve from a custom domain (e.g. `docs.example.com`): |
| 91 | + |
| 92 | +1. Add a DNS `CNAME` record (non-proxied if using Cloudflare): |
| 93 | + ``` |
| 94 | + docs.example.com CNAME <your-github-username>.github.io |
| 95 | + ``` |
| 96 | +2. Add a step to your workflow to write the `CNAME` file into the output folder (the converter wipes the output on each run, so this must be done after conversion): |
| 97 | + ```yaml |
| 98 | + - run: echo "docs.example.com" > ../site/CNAME |
| 99 | + working-directory: html-conversion |
| 100 | + ``` |
| 101 | +3. Enter the domain in **Settings → Pages → Custom domain** and wait for DNS verification. |
| 102 | +4. Once verified, enable **Enforce HTTPS**. |
| 103 | + |
| 104 | +> **Note:** If your repository belongs to a GitHub organisation that has a custom domain configured at the org level, GitHub will apply that domain automatically to all repos. In that case you either configure a per-repo custom domain as above, or complete the org-level DNS setup to make the org domain work. |
0 commit comments