- Site URL: https://knhnd.github.io/openlab-web/
astro.config.mjs
: ページ全体の設定src/content/docs/
: マークダウンでページを作成
npm run dev
- 公式ドキュメントを参考に GitHub Pages にデプロイ
basePath
を設定して開発と本番環境で自動でパスが合うように設定するsrc/utils
というフォルダを作成basePath.jd
ファイルを作成し以下を記述
export const basePath = import.meta.env.BASE_URL;
astro.config.mjs
の site と base をそれぞれ以下のように修正
site: 'https://knhnd.github.io/openlab-web/', base: '/openlab-web/', // GitHub Pages 用のベースパス
- 各ドキュメントファイル (
mdx
) では始めにimport { basePath } from '../../utils/basePath';
のように書く(import path はそれぞれの位置で変わるので注意) - リンクは
<a href={
${basePath}courses/}>Courses</a>
のようにアンカータグを使う