Static multilingual website generator for CADBase - a cloud platform for engineers and 3D creators to manage, collaborate, and share CAD projects.
CADBase is a platform that connects CAD tools like FreeCAD and Blender with cloud storage, version control, and collaboration features. This repository contains the source code for the official CADBase informational website, documentation, and blog articles.
This generator creates a static multilingual website for CADBase using Jinja2 templates. It supports three languages (English, Russian, Chinese) and generates SEO-optimized pages with proper meta tags, Open Graph, and structured data.
- Python 3.7+
- Jinja2 library
# Clone repository
git clone <repository-url>
cd cadbase-website
# Create virtual environment (recommended)
python -m venv venv
# Activate virtual environment
# On Windows:
venv\Scripts\activate
# On macOS/Linux:
source venv/bin/activate
# Install dependencies
pip install jinja2python generate-static.pyβββ generate-static.py # Main generator script
βββ i18n/
β βββ locales/
β β βββ en.json # English translations & articles
β β βββ [lang].json # Translations & articles
β βββ templates/ # Base template (header, footer, etc.)
βββ pages/
β βββ index/
β β βββ template.html # Homepage template
β βββ overviews/
β β βββ template.html # Overviews listing template
β β βββ article/
β β βββ template.html # Individual article template
β βββ privacy-notice/
β β βββ template.html # Privacy policy template
β βββ terms/
β βββ template.html # Terms of service template
βββ dist/ # Generated static site
βββ index.html # Language detection and redirect
βββ [assets]/ # CSS, JS, images
βββ [lang]/ # en/, ru/, zh/
βββ [page]/ # overviews/, terms/, etc.
βββ index.html # SPA-friendly structure
# Generate all pages for all languages
python generate-static.pyThe generator creates static HTML files in the dist/ directory:
dist/en/- English versiondist/ru/- Russian versiondist/zh/- Chinese version
Add your article to all three language files:
i18n/locales/en.json
{
"overviews": {
"articles": [
{
"page_name": "article-slug",
"title": "Article Title",
"excerpt": "Brief description of the article",
"meta": {
"title": "SEO Title",
"description": "SEO description",
"og_image": "images/og/article-image.webp",
"og_type": "article",
"author": "Author Name",
"keywords": "keyword1, keyword2"
},
"url": "overviews/article-slug/",
"published": {
"date_iso": "2024-01-15",
"date": "January 15, 2024"
},
"image": {
"path": "images/articles/article-preview.webp",
"alt": "Article preview image"
},
"content": "Full article content in HTML format",
"conclusion": "Article conclusion summary",
"next": "next-article-slug",
"reference_materials": [
"Reference 1 - Description",
"Reference 2 - Description"
],
"external": false,
"tags": ["Tag1", "Tag2", "Tag3"]
}
]
}
}Repeat for ru.json and zh.json with translated content.
Create the article content in HTML format within the content field:
"content": "<h2>Introduction</h2><p>Article content here...</p><h3>Features</h3><ul><li>Feature one</li><li>Feature two</li></ul>"Run the generator to create the new article pages:
python generate-static.pyCreate a new JSON file in i18n/locales/ (e.g., fr.json for French):
{
"meta": {
"site_name": "CADBase",
"base_url": "https://cadbase.rs/fr/",
"root_url": "https://cadbase.rs/",
"title_suffix": " - CADBase",
"description": "French description of CADBase platform",
"keywords": "french,keywords,here",
"og_image": "images/og-image.webp",
"og_type": "website",
"twitter_site": "@cadbase_rs",
"twitter_creator": "@cadbase_rs"
},
"overviews": {
"articles": [
// Add French versions of articles here
]
}
// Add other translations...
}Modify generate-static.py to include the new language:
languages = ['en', 'ru', 'zh', 'fr'] # Add new language codepython generate-static.pyThe generator currently supports:
- Homepage (
index) - Articles overview (
overviews) - Privacy policy (
privacy-notice) - Terms of service (
terms)
- Create template in
pages/new-page-type/template.html - Add page configuration in
generate-static.py:
tml = [
('new-page-type', 'path/'),
# ... existing pages
]{{ lang_code }}- Language code (en/ru/zh){{ page_name }}- Current page identifier{{ assets_prefix }}- Relative path to assets{{ meta.* }}- SEO and meta information{{ art.* }}- Article data (in article templates)
The smart_url filter handles different URL types:
- External links β
target="_blank" - Internal links β Proper relative paths
- Anchor links β Preserved as-is
Generated pages include:
- Multi-language meta tags with hreflang alternates
- Open Graph tags for social sharing
- Twitter Card meta tags
- JSON-LD structured data (Organization + Website)
- Canonical URLs
- Language-specific descriptions
The dist/ directory contains pure HTML/CSS/JS files suitable for:
- GitHub Pages
- Netlify
- Vercel
- Apache/Nginx
- AWS S3 + CloudFront
- Content Creation: Edit JSON files in
i18n/locales/ - Template Development: Modify templates in
pages/ - Generation: Run
python generate-static.py - Testing: Review generated files in
dist/ - Deployment: Upload
dist/contents to web server
Template not found
- Check template paths in
pagesconfiguration - Verify file exists in correct directory
Missing translations
- Ensure all language JSON files have the same structure
- Check for typos in variable names
Broken links
- Verify
assets_prefixconfiguration for each page type - Check URL handling in templates
Add debug output to inspect variables:
# In generate-static.py
print(f"Variables: {page_variables.keys()}")This project is part of CADBase platform. See project documentation for licensing information.
- Fork the repository
- Create a feature branch
- Add/update content in JSON files
- Test generation locally
- Submit pull request
For issues with the website generator:
- Create an issue in the repository
- Check existing JSON structure examples
- Verify Python and Jinja2 versions
Note: Always test generation locally before deploying to production. Verify all language versions are properly synchronized.