This example demonstrates how to use aliases in GenGen to create multiple URLs that point to the same content.
This site contains four pages that showcase different real-world alias scenarios:
Scenario: Multiple entry points
- Main URL:
/ - Aliases:
home.html,welcome.html,start.html - Use case: Providing multiple intuitive entry points to your site
Scenario: Company rebranding
- Main URL:
/about/ - Aliases:
oldtech-inc.html,old-company.html,company-info.html, etc. - Use case: Maintaining SEO and links after company rebranding
Scenario: Platform migration
- Main URL:
/posts/getting-started/ - Aliases: Jekyll-style URLs, WordPress URLs, tutorial URLs
- Use case: Preserving URLs when migrating from other platforms
Scenario: Multiple user mental models
- Main URL:
/contact/ - Aliases:
contact-us.html,get-in-touch.html,support.html, etc. - Use case: Accommodating different ways users think about contact information
cd examples/aliases_example
gengen buildAfter building, check the public/ directory. You'll see:
public/
├── index.html # Main homepage
├── home.html # Alias copy
├── welcome.html # Alias copy
├── start.html # Alias copy
├── about/
│ └── index.html # Main about page
├── oldtech-inc.html # Alias copy
├── old-company.html # Alias copy
├── company-info.html # Alias copy
├── posts/
│ └── getting-started/
│ └── index.html # Main blog post
├── 2024/01/15/getting-started-with-gengen.html # Alias copy
├── blog/gengen-tutorial.html # Alias copy
├── contact/
│ └── index.html # Main contact page
├── contact-us.html # Alias copy
├── get-in-touch.html # Alias copy
├── support.html # Alias copy
└── hello.html # Alias copy
If you serve the site locally, you can test that all aliases work:
# All these URLs show the same homepage content:
http://localhost:3000/
http://localhost:3000/home.html
http://localhost:3000/welcome.html
http://localhost:3000/start.html
# All these URLs show the same about page:
http://localhost:3000/about/
http://localhost:3000/oldtech-inc.html
http://localhost:3000/old-company.html
# And so on for all the aliases...The layout template includes a special section that shows all aliases for each page, making it easy to see which alternative URLs are available.
- Array format:
aliases: [alias1.html, alias2.html] - YAML list format:
aliases: - alias1.html - alias2.html
- Relative paths:
home.html - Directory paths:
blog/tutorial.html - Absolute paths:
/2024/01/15/post.html
Each page represents a common use case where aliases provide real value:
- Homepage: Multiple entry points
- About: Company rebranding
- Blog: Platform migration
- Contact: User experience optimization
- Aliases create identical copies - Not redirects, but full content copies
- File extensions are preserved - GenGen automatically handles extensions
- Directory structure is created - Subdirectories are created as needed
- SEO friendly - Each alias is a real page with full content
- Backward compatibility - Perfect for migrations and restructuring
- Modify the aliases in any of the files
- Rebuild the site with
gengen build - Check the
public/directory to see the new alias files - Test the URLs to confirm they work
This example provides a practical foundation for understanding and implementing aliases in your own GenGen sites!