Bilingual Quarto Website Implementation Summary
β Completed Tasks
1. Directory Structure Created
.
βββ zh/ # Chinese source files
β βββ _quarto.yml # Chinese-specific config
β βββ index.qmd
β βββ about.qmd
β βββ publications.qmd
βββ en/ # English source files
β βββ _quarto.yml # English-specific config
β βββ index.qmd
β βββ about.qmd
β βββ publications.qmd
βββ assets/
β βββ lang-switch.js # Language switcher JavaScript
βββ docs/
β βββ index.html # Root redirect page
β βββ zh/ # Chinese rendered output
β βββ en/ # English rendered output
β βββ assets/ # Copied from root
β βββ images/ # Copied from root
β βββ pdf/ # Copied from root
βββ _quarto.yml # Shared global config (deprecated for profiles)
βββ _quarto-zh.yml # Chinese profile config
βββ _quarto-en.yml # English profile config
βββ build.bat # Windows build script
βββ build.sh # Linux/Mac build script
βββ BUILD_GUIDE.md # Build documentation
2. Configuration Files
zh/_quarto.yml (Chinese Configuration)
- Output directory:
../docs/zh - Language: zh (Chinese)
- Chinese navbar labels
- Includes language switcher script
en/_quarto.yml (English Configuration)
- Output directory:
../docs/en - Language: en (English)
- English navbar labels
- Includes language switcher script
3. Language Switcher JavaScript
File: assets/lang-switch.js
Features: - Automatically detects current language from URL path - Shows βENβ button on Chinese pages - Shows βδΈζβ button on English pages - Maps corresponding pages: - /zh/about.html βοΈ /en/about.html - /zh/publications.html βοΈ /en/publications.html - Falls back to target language homepage if page doesnβt exist - Works with GitHub Pages subdirectory structure
How it works: 1. Runs on page load 2. Detects if URL contains /zh/ or /en/ 3. Generates the corresponding URL in the other language 4. Adds/updates a navbar link with appropriate label 5. Positions the link in the top-right of the navbar
4. Build Process
Manual Build:
# Build Chinese version
cd zh
quarto render
cd ..
# Build English version
cd en
quarto render
cd ..
# Copy resources
xcopy /E /I /Y assets docs\assets
xcopy /E /I /Y images docs\images
xcopy /E /I /Y pdf docs\pdfAutomated Build (use provided scripts):
# Windows
build.bat
# Linux/Mac
chmod +x build.sh
./build.sh5. Content Files
All content files have been created with bilingual equivalents:
Chinese (zh/): - index.qmd - Homepage with bio, education, awards - about.qmd - About page - publications.qmd - Publications and research projects
English (en/): - index.qmd - Homepage with bio, education, awards - about.qmd - About page - publications.qmd - Publications and research projects
6. Root Redirect Page
File: docs/index.html
Features: - Auto-detects browser language - Redirects Chinese users to /zh/ - Redirects others to /en/ - Provides manual links for both languages - Clean, professional fallback UI
π Deployment Instructions
For GitHub Pages:
Build the site:
build.bat # Windows ./build.sh # Linux/MacCommit all files:
git add . git commit -m "Implement bilingual website with language switcher" git pushConfigure GitHub Pages:
- Go to repository Settings > Pages
- Set source to:
mainbranch,/docsfolder - Save
Access the site:
- Root:
https://JiajunDu-ReSustain.github.io/ - Chinese:
https://JiajunDu-ReSustain.github.io/zh/ - English:
https://JiajunDu-ReSustain.github.io/en/
- Root:
π§ Maintenance
Adding New Pages
- Create
.qmdfile in bothzh/anden/with the same filename - Add navigation entry to both
zh/_quarto.ymlanden/_quarto.yml - Rebuild the site
- Language switcher will automatically handle the new page
Updating Content
- Edit the
.qmdfiles inzh/oren/ - Rebuild the affected language version
- Commit and push changes
Updating Styles
- Edit
styles.scssin the root directory - Rebuild both language versions
- Changes apply to both languages
β¨ Features
- β Fully static (no server-side logic required)
- β GitHub Pages compatible
- β Automatic language detection on root page
- β Language switcher on every page
- β Maintains URL structure when switching languages
- β Graceful fallback if page doesnβt exist
- β Clean, professional UI
- β SEO-friendly with proper lang attributes
- β Fast loading (static HTML)
- β Easy to maintain and extend
π Notes
- The language switcher uses vanilla JavaScript (no dependencies)
- Resources (images, PDFs, assets) are shared between languages
- Each language has its own search index
- The navbar is customized per language
- All paths are relative and work locally and on GitHub Pages
π Troubleshooting
Language switcher not working? - Ensure docs/assets/lang-switch.js exists - Check browser console for errors - Verify script is included in HTML (should be at end of body)
Images not loading? - Run resource copy commands after building - Verify docs/images/ and docs/pdf/ exist
Build fails? - Check Quarto version: quarto --version (should be 1.8+) - Ensure youβre in the correct directory when running render - Check for YAML syntax errors in _quarto.yml files
Wrong language on GitHub Pages? - Check docs/index.html exists and has redirect logic - Clear browser cache - Verify GitHub Pages is serving from docs/ folder
π Success!
The bilingual website is now fully implemented and ready for deployment!