SEO URL Architect
Run ID: 69c94f2ea17964d77e86d9152026-03-29SEO
PantheraHive BOS
BOS Dashboard

Design SEO-optimized URL structures, handle redirects, and create URL taxonomy for site sections.

SEO URL Architecture Design & Strategy

This document outlines a comprehensive strategy for designing SEO-optimized URL structures, establishing a robust redirect handling protocol, and creating a logical URL taxonomy for your site sections. This deliverable is crucial for enhancing search engine visibility, improving user experience, and ensuring long-term site health.


1. Executive Summary

A well-structured URL architecture is fundamental for SEO success. It helps search engines understand your site's hierarchy and content relevance, while also providing a clear, user-friendly experience. This strategy focuses on creating clean, keyword-rich, and consistent URLs, alongside a meticulous plan for managing redirects to preserve SEO value during site changes, and a logical taxonomy to organize your digital assets effectively.


2. Principles of SEO-Optimized URL Structures

The following principles guide the design of effective, SEO-friendly URLs:

  • Readability & User-Friendliness: URLs should be easy for humans to read, understand, and remember. They should convey the content of the page at a glance.

Actionable:* Avoid obscure IDs or long strings of unrelated characters.

  • Keyword Inclusion: Incorporate relevant keywords where natural and logical. This helps search engines understand the page's topic and can improve click-through rates (CTR) in search results.

Actionable:* Prioritize primary keywords for the page's content.

  • Hierarchy & Structure: URLs should reflect the site's logical hierarchy, making it clear how pages relate to one another. This aids both users and search engines in navigating the site.

Actionable:* Use a consistent path structure (e.g., /category/subcategory/product-name).

  • Conciseness: Shorter URLs are generally preferred, as they are easier to share, remember, and less prone to truncation in search results.

Actionable:* Eliminate unnecessary words or parameters.

  • Static vs. Dynamic: Prioritize static, descriptive URLs over dynamic URLs with multiple parameters, which can be harder for search engines to crawl and index.

Actionable:* Implement URL rewriting to convert dynamic URLs to static ones if your CMS generates dynamic paths by default.

  • Consistency: Maintain a consistent URL structure across similar content types.

Actionable:* Define a clear pattern for each content type (e.g., all blog posts follow /blog/post-title).


3. Recommended URL Structure Models

We recommend the following URL structure models for different types of content on your site:

3.1. E-commerce / Product Pages

  • Goal: Clear category hierarchy, product identification, and keyword relevance.
  • Model: https://www.yourdomain.com/category/subcategory/product-name/
  • Example:

* https://www.yourdomain.com/electronics/laptops/macbook-pro-16-inch/

* https://www.yourdomain.com/apparel/mens/t-shirts/graphic-tee-summer-edition/

  • Notes:

* Ensure category and subcategory names are descriptive and keyword-rich.

* Product names should be unique and reflect the actual product title.

* Avoid including product IDs unless absolutely necessary for system functionality, and even then, consider canonicalization.

3.2. Blog / Article Pages

  • Goal: Readability, topical relevance, and potential for date-based organization if relevant.
  • Model 1 (Category-based): https://www.yourdomain.com/blog/category-name/article-title/

* Example: https://www.yourdomain.com/blog/seo-tips/how-to-optimize-your-urls/

  • Model 2 (Flat - for smaller blogs or specific topics): https://www.yourdomain.com/blog/article-title/

* Example: https://www.yourdomain.com/blog/ultimate-guide-to-keyword-research/

  • Notes:

* Choose one model and stick to it for consistency.

* Article titles should be descriptive and include primary keywords.

* Avoid including dates in the URL unless the content is highly time-sensitive and will not be updated (e.g., news archives). If dates are included, ensure a clear redirect strategy for updated content.

3.3. Service Pages

  • Goal: Clear identification of specific services offered.
  • Model: https://www.yourdomain.com/services/service-name/
  • Example:

* https://www.yourdomain.com/services/web-design/

* https://www.yourdomain.com/services/seo-consulting/

  • Notes:

* Service names should be concise and accurately reflect the service.

3.4. Static / Informational Pages (About Us, Contact, Privacy Policy)

  • Goal: Simplicity and directness.
  • Model: https://www.yourdomain.com/page-name/
  • Example:

* https://www.yourdomain.com/about-us/

* https://www.yourdomain.com/contact/

* https://www.yourdomain.com/privacy-policy/

  • Notes:

* These pages typically reside at the root level for easy access.


4. URL Best Practices & Technical Considerations

To ensure maximum SEO benefit and prevent common pitfalls:

  • Use Hyphens (-) for Word Separation: Always use hyphens to separate words in URLs. Underscores (_) are treated as word joiners by Google, which can hinder keyword recognition.

Actionable:* Implement a rule to automatically convert spaces or other separators to hyphens.

  • All Lowercase: All URLs should be lowercase to prevent duplicate content issues (e.g., /Page vs /page could be seen as two different URLs).

Actionable:* Configure your server/CMS to automatically redirect uppercase URLs to their lowercase equivalents (301 redirect).

  • Trailing Slashes: Decide on a consistent trailing slash policy (either always include or always omit) and enforce it with 301 redirects to avoid duplicate content.

Actionable:* Configure your server to redirect /page/ to /page or vice-versa, ensuring only one version is accessible.

  • Avoid Dynamic Parameters Where Possible: URLs with parameters like ?id=123&sort=price are less SEO-friendly. If dynamic parameters are unavoidable (e.g., for filtering/sorting), ensure they are properly handled with canonical tags or robot.txt disallow rules.

Actionable:* Utilize URL rewriting modules (e.g., Apache's mod_rewrite, Nginx rewrite) to create clean URLs.

  • Canonicalization: For pages with similar or duplicate content (e.g., product pages accessible via multiple categories, paginated archives), use the rel="canonical" tag to specify the preferred version to search engines.

Actionable:* Implement canonical tags on all pages to point to their self-referencing canonical URL, or to the preferred version if duplicates exist.

  • HTTPS: All URLs should be served over HTTPS for security, trust, and SEO benefits.

Actionable:* Ensure all HTTP versions of URLs 301 redirect to their HTTPS counterparts.

  • URL Length: Aim for URLs that are concise but descriptive. While there's no strict limit, shorter URLs are generally better.

Actionable:* Review generated URLs for excessive length and simplify where possible without losing meaning.


5. Comprehensive Redirect Handling Strategy

Redirects are critical for maintaining SEO value, user experience, and preventing broken links when URLs change or pages are removed.

5.1. Types of Redirects

  • 301 Permanent Redirect:

* Purpose: Indicates that a page has permanently moved to a new location.

* SEO Impact: Passes almost all (90-99%) link equity (PageRank) to the new URL. This is the preferred redirect for permanent URL changes.

* When to Use:

* Site redesigns or migrations where URLs change.

* Changing URL structure (e.g., from dynamic to static).

* Consolidating duplicate content.

* Migrating from HTTP to HTTPS.

* Removing old or outdated pages that have link equity.

  • 302 Found (Temporary Redirect):

* Purpose: Indicates that a page has temporarily moved to a new location, but might return to its original URL in the future.

* SEO Impact: Passes little to no link equity. Search engines will typically keep the original URL in their index.

* When to Use:

* A/B testing a new page design.

* Temporary promotions or sales pages.

* Short-term site maintenance.

* Geo-targeting redirects (though often handled differently now).

  • 307 Temporary Redirect (HTTP/1.1):

* Purpose: Similar to 302, but explicitly states that the request method (GET, POST) should not be changed when redirecting.

* SEO Impact: Similar to 302, passes little to no link equity.

* When to Use: When strict adherence to the original HTTP request method is required, typically in specific application scenarios. Less common for general SEO.

  • 308 Permanent Redirect (HTTP/1.1):

* Purpose: Similar to 301, but explicitly states that the request method should not be changed.

* SEO Impact: Similar to 301, passes link equity.

* When to Use: When a permanent redirect is needed, and it's critical to preserve the HTTP method (e.g., for POST requests).

5.2. Common Scenarios for Redirects

  • Site Migrations/Redesigns: Every old URL must map to its new equivalent.
  • URL Structure Changes: When implementing new URL patterns.
  • Content Updates/Consolidation: Merging multiple pages into one, or updating an old page with a new URL.
  • Broken Links (404 Errors): Identify and redirect external and internal 404s to relevant live pages or a custom 404 page.
  • HTTP to HTTPS Migration: All HTTP URLs must 301 redirect to HTTPS.
  • Non-www to www (or vice-versa): Choose a preferred domain and 301 redirect the other version.
  • Trailing Slash Enforcement: Redirect non-preferred trailing slash versions to the preferred one.

5.3. Redirect Management Best Practices

  • Prioritize 301 Redirects: For any permanent URL change, always use a 301 redirect to preserve SEO value.
  • Avoid Redirect Chains: A redirect chain occurs when URL A redirects to URL B, which then redirects to URL C. This degrades user experience, slows down page load, and can dilute link equity.

Actionable:* Implement direct redirects (URL A -> URL C). Regularly audit your redirects to identify and fix chains.

  • Wildcard Redirects: Use wildcard redirects (*) for broad pattern matches (e.g., redirecting an entire old directory to a new one) to save time and reduce errors.

Actionable: Example: RedirectMatch 301 ^/old-category/(.)$ https://www.yourdomain.com/new-category/$1

  • Regular Audits: Periodically audit your site for broken links (404s) and redirect chains.

Actionable:* Utilize tools like Screaming Frog, Google Search Console, or Ahrefs to monitor for redirect issues.

  • Test Redirects: Before going live, thoroughly test all redirects to ensure they function correctly and lead to the intended destination.

Actionable:* Use browser developer tools or online redirect checkers.

  • Maintain a Redirect Map: Keep a detailed spreadsheet or database of all old URLs and their corresponding new URLs. This is invaluable for future reference and troubleshooting.

6. URL Taxonomy Design for Site Sections

URL taxonomy refers to the hierarchical and logical organization of your site's content, reflected in its URL structure. A well-designed taxonomy enhances navigability for users and crawlability for search engines.

6.1. Definition & Benefits

  • Definition: The systematic classification and organization of content into a hierarchical structure, which is then mirrored in the URL paths.
  • Benefits:

* Improved User Experience (UX): Users can easily understand where they are on the site and how to navigate.

* Enhanced SEO: Search engines better understand your site's structure, the relationship between pages, and the topical authority of different sections.

* Better Crawlability: A clear hierarchy helps search engine spiders efficiently discover and index new content.

* Scalability: A logical taxonomy makes it easier to add new content and sections in the future without disrupting the overall structure.

6.2. Hierarchical Structure Approach

The most effective taxonomy follows a logical, top-down hierarchy:

  • Root Level: The main domain (yourdomain.com).
  • Primary Categories: Broad content areas (e.g., /electronics/, /apparel/, /blog/, /services/).
  • Subcategories: More specific divisions within primary categories (e.g., /electronics/laptops/, /apparel/mens/).
  • Individual Pages/Products: The most granular level of content (e.g., /electronics/laptops/macbook-pro-16-inch/, /blog/seo-tips/how-to-optimize-your-urls/).

6.3. Examples of Taxonomy Implementation

  • E-commerce Site:

* /electronics/

* /electronics/laptops/

* /electronics/laptops/macbook-pro-16-inch/

* /electronics/laptops/dell-xps-13/

* /electronics/smartphones/

* /electronics/smartphones/iphone-15/

* /apparel/

* /apparel/mens/

* /apparel/womens/

  • Blog/Content Site:

* /blog/

* /blog/seo-tips/

* /blog/seo-tips/how-to-optimize-your-urls/

* /blog/content-marketing/

* /blog/content-marketing/guide-to-blogging/

  • Service-Based Business:

* /services/

* /services/web-design/

* `/services

gemini Output

This document outlines a comprehensive strategy for designing SEO-optimized URL structures, managing redirects, and establishing a robust URL taxonomy for your website. Implementing these recommendations will enhance search engine visibility, improve user experience, and ensure long-term scalability of your site's architecture.


SEO URL Architect: Deliverable

1. Introduction

A well-structured URL is a foundational element of effective SEO. It not only helps search engines understand the hierarchy and content of your pages but also provides a clear, user-friendly experience. This deliverable provides a detailed framework for creating SEO-friendly URLs, managing necessary redirects, and establishing a logical URL taxonomy across your site sections.

2. SEO-Optimized URL Structures

The goal is to create URLs that are both descriptive for users and easily crawlable and indexable for search engines.

2.1 Core Principles for URL Design

  • Readability & User-Friendliness: URLs should be easy to read, understand, and remember. Avoid obscure codes or long strings of numbers.

Good*: yourdomain.com/blog/seo-url-architecture

Bad*: yourdomain.com/post.php?id=123&cat=45

  • Keyword Inclusion: Integrate relevant keywords naturally, but avoid keyword stuffing. The primary keyword for the page should ideally appear in the URL.

Example*: For a page about "best hiking boots for women," the URL could be /hiking-boots/women/best-hiking-boots-for-women/.

  • Conciseness: Keep URLs as short as possible without sacrificing clarity or keyword inclusion. Shorter URLs are easier to share and less prone to truncation in SERPs.
  • Hyphens as Separators: Use hyphens (-) to separate words in URLs. Avoid underscores (_), spaces, or other characters.

Good*: seo-url-architecture

Bad*: seo_url_architecture or seo url architecture

  • Lowercase: All URLs should be lowercase. This prevents potential duplicate content issues (e.g., yourdomain.com/Page and yourdomain.com/page being treated as separate URLs by some servers).
  • Static URLs: Prioritize static URLs over dynamic ones where possible. If dynamic parameters are unavoidable, keep them minimal and ensure they don't create duplicate content issues (using rel="canonical").
  • HTTPS: Ensure all URLs are served over HTTPS for security, user trust, and SEO benefit. This is a non-negotiable standard.
  • No Trailing Slashes (or consistent use): Decide whether your URLs will end with a trailing slash (e.g., /page/) or without (e.g., /page). Implement a 301 redirect to enforce consistency across the entire site. Generally, for files, no trailing slash, for directories, use a trailing slash. Consistency is key.

2.2 URL Structure Examples by Content Type

Below are recommended URL structures for common website content types:

  • Homepage: yourdomain.com/
  • Static Pages (About, Contact, Privacy Policy):

* /about-us/

* /contact/

* /privacy-policy/

  • Blog Posts:

* Option A (Category-based): yourdomain.com/blog/category-slug/post-title-slug/

Example*: yourdomain.com/blog/seo-tips/understanding-url-architecture/

* Option B (Date-based - less common for SEO benefit): yourdomain.com/blog/yyyy/mm/post-title-slug/

Example*: yourdomain.com/blog/2023/10/understanding-url-architecture/

Recommendation*: Option A is generally preferred for evergreen content, as it keeps URLs relevant over time.

  • Product Categories (E-commerce):

* /category-slug/

* /category-slug/subcategory-slug/

Example*: yourdomain.com/electronics/ or yourdomain.com/electronics/smartphones/

  • Product Pages (E-commerce):

* Option A (Category-nested): yourdomain.com/category-slug/subcategory-slug/product-name-slug/

Example*: yourdomain.com/electronics/smartphones/iphone-15-pro-max/

* Option B (Flat Product Structure): yourdomain.com/products/product-name-slug/

Example*: yourdomain.com/products/iphone-15-pro-max/

Recommendation*: Option A is often better for conveying hierarchy and keyword relevance. Ensure canonicalization is correctly implemented if products appear in multiple categories.

  • Services:

* /services/service-type-slug/

* /services/service-type-slug/individual-service-page-slug/

Example*: yourdomain.com/services/web-design/ or yourdomain.com/services/web-design/e-commerce-solutions/

  • Authors (for blogs/news sites):

* /author/author-name-slug/

Example*: yourdomain.com/author/jane-doe/

3. Redirect Strategy

Redirects are crucial for maintaining link equity, preserving user experience, and preventing 404 errors when URLs change.

3.1 Types of Redirects

  • 301 Permanent Redirect:

* Purpose: Indicates that a page has permanently moved to a new location.

* SEO Impact: Passes almost all (90-99%) of the link equity (PageRank) from the old URL to the new URL. This is the preferred redirect for permanent changes.

* When to Use: Site migrations, permanent URL changes, consolidating duplicate content.

  • 302 Found (Temporary Redirect):

* Purpose: Indicates that a page has temporarily moved. The server expects the client to continue requesting the old URL in the future.

* SEO Impact: Passes little to no link equity. Search engines will typically keep the old URL in their index.

* When to Use: A/B testing, temporary promotions, maintenance pages that will be reverted. Avoid for permanent changes.

  • 307 Temporary Redirect:

* Purpose: HTTP 1.1 equivalent of 302, but specifically preserves the HTTP method (e.g., POST request).

* SEO Impact: Similar to 302, passes little to no link equity.

* When to Use: Specific development scenarios where method preservation is critical. Not generally recommended for SEO purposes.

  • Meta Refresh & JavaScript Redirects:

* Purpose: Client-side redirects using HTML <meta> tags or JavaScript.

* SEO Impact: Generally not recommended for SEO as they can be slower, may not pass link equity effectively, and can be perceived negatively by search engines.

3.2 When to Implement Redirects

  • Site Migrations: Moving from one domain to another (e.g., olddomain.com to newdomain.com).
  • URL Changes: When you update or rename a page's URL slug (e.g., /old-product-name/ to /new-product-name/).
  • Content Consolidation: Merging multiple similar pages into a single, more comprehensive page.
  • Fixing Broken Links: Redirecting old, non-existent URLs (404s) to relevant live pages.
  • Enforcing HTTPS: Redirecting all HTTP traffic to HTTPS (e.g., http://yourdomain.com to https://yourdomain.com).
  • Enforcing WWW/Non-WWW: Redirecting one version to the other (e.g., www.yourdomain.com to yourdomain.com or vice-versa).
  • Trailing Slash Consistency: Redirecting yourdomain.com/page to yourdomain.com/page/ (or vice-versa) to prevent duplicate content.

3.3 Redirect Implementation Best Practices

  • Prioritize 301 Redirects: For any permanent URL change, use 301 redirects to preserve SEO value.
  • Minimize Redirect Chains: Avoid redirecting URL A to URL B which then redirects to URL C. Aim for direct URL A -> URL C redirects. Chains can slow down page load times and dilute link equity.
  • One-to-One Mapping: Whenever possible, map old URLs directly to their most relevant new counterparts. Avoid redirecting many old URLs to a single homepage, unless there's no more specific relevant page.
  • Wildcard Redirects: Use with caution. They are useful for redirecting entire sections (e.g., olddomain.com/blog/ to newdomain.com/blog/) but ensure they don't create redirect loops or redirect to irrelevant pages.
  • Regular Auditing: Periodically audit your redirects to identify broken redirects, redirect chains, or unexpected 404s. Tools like Screaming Frog, Ahrefs, or Google Search Console can assist.
  • Server-Side Implementation: Implement redirects at the server level (e.g., via .htaccess for Apache, nginx.conf for Nginx, or server-side code) for optimal performance and SEO benefits. Avoid client-side redirects for permanent moves.

4. URL Taxonomy for Site Sections

A well-defined URL taxonomy mirrors your site's information architecture, making it intuitive for both users and search engines to navigate and understand your content.

4.1 Principles for Taxonomy Design

  • Reflect Information Architecture: Your URL structure should visually represent the logical hierarchy of your website. This often aligns with your main navigation.
  • Consistency: Apply a consistent pattern across similar sections of your site. If product URLs are /category/product-name/, then service URLs should follow a similar /service-type/service-name/ pattern.
  • Logical Grouping: Group related content together under logical parent URLs. This helps users and search engines understand the relationship between pages.
  • Scalability: Design a taxonomy that can easily accommodate future growth without requiring a complete overhaul. Avoid overly specific or rigid structures that might break with new content types.
  • User Experience (UX): A good URL taxonomy enhances UX by providing clear breadcrumbs and context. Users should be able to infer their location on the site from the URL alone.
  • Avoid Excessive Depth: While hierarchy is good, overly deep URL structures (e.g., more than 3-4 subdirectories) can become cumbersome and may signal lower importance to search engines.

Good*: yourdomain.com/category/subcategory/product/

Avoid*: yourdomain.com/level1/level2/level3/level4/level5/product/

4.2 Taxonomy Examples by Site Section

  • E-commerce Website:

* yourdomain.com/electronics/ (Category)

* yourdomain.com/electronics/smartphones/ (Subcategory)

* yourdomain.com/electronics/smartphones/iphone-15-pro-max/ (Product)

* yourdomain.com/accessories/ (Another Category)

* yourdomain.com/accessories/phone-cases/ (Subcategory)

  • Blog/Content Hub:

* `yourdomain.

Copy all content
Full output as text
Download ZIP
IDE-ready project ZIP
Copy share link
Permanent URL for this run
Get Embed Code
Embed this result on any website
Print / Save PDF
Use browser print dialog
\n\n\n"); var hasSrcMain=Object.keys(extracted).some(function(k){return k.indexOf("src/main")>=0;}); if(!hasSrcMain) zip.file(folder+"src/main."+ext,"import React from 'react'\nimport ReactDOM from 'react-dom/client'\nimport App from './App'\nimport './index.css'\n\nReactDOM.createRoot(document.getElementById('root')!).render(\n \n \n \n)\n"); var hasSrcApp=Object.keys(extracted).some(function(k){return k==="src/App."+ext||k==="App."+ext;}); if(!hasSrcApp) zip.file(folder+"src/App."+ext,"import React from 'react'\nimport './App.css'\n\nfunction App(){\n return(\n
\n
\n

"+slugTitle(pn)+"

\n

Built with PantheraHive BOS

\n
\n
\n )\n}\nexport default App\n"); zip.file(folder+"src/index.css","*{margin:0;padding:0;box-sizing:border-box}\nbody{font-family:system-ui,-apple-system,sans-serif;background:#f0f2f5;color:#1a1a2e}\n.app{min-height:100vh;display:flex;flex-direction:column}\n.app-header{flex:1;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:12px;padding:40px}\nh1{font-size:2.5rem;font-weight:700}\n"); zip.file(folder+"src/App.css",""); zip.file(folder+"src/components/.gitkeep",""); zip.file(folder+"src/pages/.gitkeep",""); zip.file(folder+"src/hooks/.gitkeep",""); Object.keys(extracted).forEach(function(p){ var fp=p.startsWith("src/")?p:"src/"+p; zip.file(folder+fp,extracted[p]); }); zip.file(folder+"README.md","# "+slugTitle(pn)+"\n\nGenerated by PantheraHive BOS.\n\n## Setup\n\`\`\`bash\nnpm install\nnpm run dev\n\`\`\`\n\n## Build\n\`\`\`bash\nnpm run build\n\`\`\`\n\n## Open in IDE\nOpen the project folder in VS Code or WebStorm.\n"); zip.file(folder+".gitignore","node_modules/\ndist/\n.env\n.DS_Store\n*.local\n"); } /* --- Vue (Vite + Composition API + TypeScript) --- */ function buildVue(zip,folder,app,code,panelTxt){ var pn=pkgName(app); var C=cc(pn); var extracted=extractCode(panelTxt); zip.file(folder+"package.json",'{\n "name": "'+pn+'",\n "version": "0.0.0",\n "type": "module",\n "scripts": {\n "dev": "vite",\n "build": "vue-tsc -b && vite build",\n "preview": "vite preview"\n },\n "dependencies": {\n "vue": "^3.5.13",\n "vue-router": "^4.4.5",\n "pinia": "^2.3.0",\n "axios": "^1.7.9"\n },\n "devDependencies": {\n "@vitejs/plugin-vue": "^5.2.1",\n "typescript": "~5.7.3",\n "vite": "^6.0.5",\n "vue-tsc": "^2.2.0"\n }\n}\n'); zip.file(folder+"vite.config.ts","import { defineConfig } from 'vite'\nimport vue from '@vitejs/plugin-vue'\nimport { resolve } from 'path'\n\nexport default defineConfig({\n plugins: [vue()],\n resolve: { alias: { '@': resolve(__dirname,'src') } }\n})\n"); zip.file(folder+"tsconfig.json",'{"files":[],"references":[{"path":"./tsconfig.app.json"},{"path":"./tsconfig.node.json"}]}\n'); zip.file(folder+"tsconfig.app.json",'{\n "compilerOptions":{\n "target":"ES2020","useDefineForClassFields":true,"module":"ESNext","lib":["ES2020","DOM","DOM.Iterable"],\n "skipLibCheck":true,"moduleResolution":"bundler","allowImportingTsExtensions":true,\n "isolatedModules":true,"moduleDetection":"force","noEmit":true,"jsxImportSource":"vue",\n "strict":true,"paths":{"@/*":["./src/*"]}\n },\n "include":["src/**/*.ts","src/**/*.d.ts","src/**/*.tsx","src/**/*.vue"]\n}\n'); zip.file(folder+"env.d.ts","/// \n"); zip.file(folder+"index.html","\n\n\n \n \n "+slugTitle(pn)+"\n\n\n
\n \n\n\n"); var hasMain=Object.keys(extracted).some(function(k){return k==="src/main.ts"||k==="main.ts";}); if(!hasMain) zip.file(folder+"src/main.ts","import { createApp } from 'vue'\nimport { createPinia } from 'pinia'\nimport App from './App.vue'\nimport './assets/main.css'\n\nconst app = createApp(App)\napp.use(createPinia())\napp.mount('#app')\n"); var hasApp=Object.keys(extracted).some(function(k){return k.indexOf("App.vue")>=0;}); if(!hasApp) zip.file(folder+"src/App.vue","\n\n\n\n\n"); zip.file(folder+"src/assets/main.css","*{margin:0;padding:0;box-sizing:border-box}body{font-family:system-ui,sans-serif;background:#fff;color:#213547}\n"); zip.file(folder+"src/components/.gitkeep",""); zip.file(folder+"src/views/.gitkeep",""); zip.file(folder+"src/stores/.gitkeep",""); Object.keys(extracted).forEach(function(p){ var fp=p.startsWith("src/")?p:"src/"+p; zip.file(folder+fp,extracted[p]); }); zip.file(folder+"README.md","# "+slugTitle(pn)+"\n\nGenerated by PantheraHive BOS.\n\n## Setup\n\`\`\`bash\nnpm install\nnpm run dev\n\`\`\`\n\n## Build\n\`\`\`bash\nnpm run build\n\`\`\`\n\nOpen in VS Code or WebStorm.\n"); zip.file(folder+".gitignore","node_modules/\ndist/\n.env\n.DS_Store\n*.local\n"); } /* --- Angular (v19 standalone) --- */ function buildAngular(zip,folder,app,code,panelTxt){ var pn=pkgName(app); var C=cc(pn); var sel=pn.replace(/_/g,"-"); var extracted=extractCode(panelTxt); zip.file(folder+"package.json",'{\n "name": "'+pn+'",\n "version": "0.0.0",\n "scripts": {\n "ng": "ng",\n "start": "ng serve",\n "build": "ng build",\n "test": "ng test"\n },\n "dependencies": {\n "@angular/animations": "^19.0.0",\n "@angular/common": "^19.0.0",\n "@angular/compiler": "^19.0.0",\n "@angular/core": "^19.0.0",\n "@angular/forms": "^19.0.0",\n "@angular/platform-browser": "^19.0.0",\n "@angular/platform-browser-dynamic": "^19.0.0",\n "@angular/router": "^19.0.0",\n "rxjs": "~7.8.0",\n "tslib": "^2.3.0",\n "zone.js": "~0.15.0"\n },\n "devDependencies": {\n "@angular-devkit/build-angular": "^19.0.0",\n "@angular/cli": "^19.0.0",\n "@angular/compiler-cli": "^19.0.0",\n "typescript": "~5.6.0"\n }\n}\n'); zip.file(folder+"angular.json",'{\n "$schema": "./node_modules/@angular/cli/lib/config/schema.json",\n "version": 1,\n "newProjectRoot": "projects",\n "projects": {\n "'+pn+'": {\n "projectType": "application",\n "root": "",\n "sourceRoot": "src",\n "prefix": "app",\n "architect": {\n "build": {\n "builder": "@angular-devkit/build-angular:application",\n "options": {\n "outputPath": "dist/'+pn+'",\n "index": "src/index.html",\n "browser": "src/main.ts",\n "tsConfig": "tsconfig.app.json",\n "styles": ["src/styles.css"],\n "scripts": []\n }\n },\n "serve": {"builder":"@angular-devkit/build-angular:dev-server","configurations":{"production":{"buildTarget":"'+pn+':build:production"},"development":{"buildTarget":"'+pn+':build:development"}},"defaultConfiguration":"development"}\n }\n }\n }\n}\n'); zip.file(folder+"tsconfig.json",'{\n "compileOnSave": false,\n "compilerOptions": {"baseUrl":"./","outDir":"./dist/out-tsc","forceConsistentCasingInFileNames":true,"strict":true,"noImplicitOverride":true,"noPropertyAccessFromIndexSignature":true,"noImplicitReturns":true,"noFallthroughCasesInSwitch":true,"paths":{"@/*":["src/*"]},"skipLibCheck":true,"esModuleInterop":true,"sourceMap":true,"declaration":false,"experimentalDecorators":true,"moduleResolution":"bundler","importHelpers":true,"target":"ES2022","module":"ES2022","useDefineForClassFields":false,"lib":["ES2022","dom"]},\n "references":[{"path":"./tsconfig.app.json"}]\n}\n'); zip.file(folder+"tsconfig.app.json",'{\n "extends":"./tsconfig.json",\n "compilerOptions":{"outDir":"./dist/out-tsc","types":[]},\n "files":["src/main.ts"],\n "include":["src/**/*.d.ts"]\n}\n'); zip.file(folder+"src/index.html","\n\n\n \n "+slugTitle(pn)+"\n \n \n \n\n\n \n\n\n"); zip.file(folder+"src/main.ts","import { bootstrapApplication } from '@angular/platform-browser';\nimport { appConfig } from './app/app.config';\nimport { AppComponent } from './app/app.component';\n\nbootstrapApplication(AppComponent, appConfig)\n .catch(err => console.error(err));\n"); zip.file(folder+"src/styles.css","* { margin: 0; padding: 0; box-sizing: border-box; }\nbody { font-family: system-ui, -apple-system, sans-serif; background: #f9fafb; color: #111827; }\n"); var hasComp=Object.keys(extracted).some(function(k){return k.indexOf("app.component")>=0;}); if(!hasComp){ zip.file(folder+"src/app/app.component.ts","import { Component } from '@angular/core';\nimport { RouterOutlet } from '@angular/router';\n\n@Component({\n selector: 'app-root',\n standalone: true,\n imports: [RouterOutlet],\n templateUrl: './app.component.html',\n styleUrl: './app.component.css'\n})\nexport class AppComponent {\n title = '"+pn+"';\n}\n"); zip.file(folder+"src/app/app.component.html","
\n
\n

"+slugTitle(pn)+"

\n

Built with PantheraHive BOS

\n
\n \n
\n"); zip.file(folder+"src/app/app.component.css",".app-header{display:flex;flex-direction:column;align-items:center;justify-content:center;min-height:60vh;gap:16px}h1{font-size:2.5rem;font-weight:700;color:#6366f1}\n"); } zip.file(folder+"src/app/app.config.ts","import { ApplicationConfig, provideZoneChangeDetection } from '@angular/core';\nimport { provideRouter } from '@angular/router';\nimport { routes } from './app.routes';\n\nexport const appConfig: ApplicationConfig = {\n providers: [\n provideZoneChangeDetection({ eventCoalescing: true }),\n provideRouter(routes)\n ]\n};\n"); zip.file(folder+"src/app/app.routes.ts","import { Routes } from '@angular/router';\n\nexport const routes: Routes = [];\n"); Object.keys(extracted).forEach(function(p){ var fp=p.startsWith("src/")?p:"src/"+p; zip.file(folder+fp,extracted[p]); }); zip.file(folder+"README.md","# "+slugTitle(pn)+"\n\nGenerated by PantheraHive BOS.\n\n## Setup\n\`\`\`bash\nnpm install\nng serve\n# or: npm start\n\`\`\`\n\n## Build\n\`\`\`bash\nng build\n\`\`\`\n\nOpen in VS Code with Angular Language Service extension.\n"); zip.file(folder+".gitignore","node_modules/\ndist/\n.env\n.DS_Store\n*.local\n.angular/\n"); } /* --- Python --- */ function buildPython(zip,folder,app,code){ var title=slugTitle(app); var pn=pkgName(app); var src=code.replace(/^\`\`\`[\w]*\n?/m,"").replace(/\n?\`\`\`$/m,"").trim(); var reqMap={"numpy":"numpy","pandas":"pandas","sklearn":"scikit-learn","tensorflow":"tensorflow","torch":"torch","flask":"flask","fastapi":"fastapi","uvicorn":"uvicorn","requests":"requests","sqlalchemy":"sqlalchemy","pydantic":"pydantic","dotenv":"python-dotenv","PIL":"Pillow","cv2":"opencv-python","matplotlib":"matplotlib","seaborn":"seaborn","scipy":"scipy"}; var reqs=[]; Object.keys(reqMap).forEach(function(k){if(src.indexOf("import "+k)>=0||src.indexOf("from "+k)>=0)reqs.push(reqMap[k]);}); var reqsTxt=reqs.length?reqs.join("\n"):"# add dependencies here\n"; zip.file(folder+"main.py",src||"# "+title+"\n# Generated by PantheraHive BOS\n\nprint(title+\" loaded\")\n"); zip.file(folder+"requirements.txt",reqsTxt); zip.file(folder+".env.example","# Environment variables\n"); zip.file(folder+"README.md","# "+title+"\n\nGenerated by PantheraHive BOS.\n\n## Setup\n\`\`\`bash\npython3 -m venv .venv\nsource .venv/bin/activate\npip install -r requirements.txt\n\`\`\`\n\n## Run\n\`\`\`bash\npython main.py\n\`\`\`\n"); zip.file(folder+".gitignore",".venv/\n__pycache__/\n*.pyc\n.env\n.DS_Store\n"); } /* --- Node.js --- */ function buildNode(zip,folder,app,code){ var title=slugTitle(app); var pn=pkgName(app); var src=code.replace(/^\`\`\`[\w]*\n?/m,"").replace(/\n?\`\`\`$/m,"").trim(); var depMap={"mongoose":"^8.0.0","dotenv":"^16.4.5","axios":"^1.7.9","cors":"^2.8.5","bcryptjs":"^2.4.3","jsonwebtoken":"^9.0.2","socket.io":"^4.7.4","uuid":"^9.0.1","zod":"^3.22.4","express":"^4.18.2"}; var deps={}; Object.keys(depMap).forEach(function(k){if(src.indexOf(k)>=0)deps[k]=depMap[k];}); if(!deps["express"])deps["express"]="^4.18.2"; var pkgJson=JSON.stringify({"name":pn,"version":"1.0.0","main":"src/index.js","scripts":{"start":"node src/index.js","dev":"nodemon src/index.js"},"dependencies":deps,"devDependencies":{"nodemon":"^3.0.3"}},null,2)+"\n"; zip.file(folder+"package.json",pkgJson); var fallback="const express=require(\"express\");\nconst app=express();\napp.use(express.json());\n\napp.get(\"/\",(req,res)=>{\n res.json({message:\""+title+" API\"});\n});\n\nconst PORT=process.env.PORT||3000;\napp.listen(PORT,()=>console.log(\"Server on port \"+PORT));\n"; zip.file(folder+"src/index.js",src||fallback); zip.file(folder+".env.example","PORT=3000\n"); zip.file(folder+".gitignore","node_modules/\n.env\n.DS_Store\n"); zip.file(folder+"README.md","# "+title+"\n\nGenerated by PantheraHive BOS.\n\n## Setup\n\`\`\`bash\nnpm install\n\`\`\`\n\n## Run\n\`\`\`bash\nnpm run dev\n\`\`\`\n"); } /* --- Vanilla HTML --- */ function buildVanillaHtml(zip,folder,app,code){ var title=slugTitle(app); var isFullDoc=code.trim().toLowerCase().indexOf("=0||code.trim().toLowerCase().indexOf("=0; var indexHtml=isFullDoc?code:"\n\n\n\n\n"+title+"\n\n\n\n"+code+"\n\n\n\n"; zip.file(folder+"index.html",indexHtml); zip.file(folder+"style.css","/* "+title+" — styles */\n*{margin:0;padding:0;box-sizing:border-box}\nbody{font-family:system-ui,-apple-system,sans-serif;background:#fff;color:#1a1a2e}\n"); zip.file(folder+"script.js","/* "+title+" — scripts */\n"); zip.file(folder+"assets/.gitkeep",""); zip.file(folder+"README.md","# "+title+"\n\nGenerated by PantheraHive BOS.\n\n## Open\nDouble-click \`index.html\` in your browser.\n\nOr serve locally:\n\`\`\`bash\nnpx serve .\n# or\npython3 -m http.server 3000\n\`\`\`\n"); zip.file(folder+".gitignore",".DS_Store\nnode_modules/\n.env\n"); } /* ===== MAIN ===== */ var sc=document.createElement("script"); sc.src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.10.1/jszip.min.js"; sc.onerror=function(){ if(lbl)lbl.textContent="Download ZIP"; alert("JSZip load failed — check connection."); }; sc.onload=function(){ var zip=new JSZip(); var base=(_phFname||"output").replace(/\.[^.]+$/,""); var app=base.toLowerCase().replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,"")||"my_app"; var folder=app+"/"; var vc=document.getElementById("panel-content"); var panelTxt=vc?(vc.innerText||vc.textContent||""):""; var lang=detectLang(_phCode,panelTxt); if(_phIsHtml){ buildVanillaHtml(zip,folder,app,_phCode); } else if(lang==="flutter"){ buildFlutter(zip,folder,app,_phCode,panelTxt); } else if(lang==="react-native"){ buildReactNative(zip,folder,app,_phCode,panelTxt); } else if(lang==="swift"){ buildSwift(zip,folder,app,_phCode,panelTxt); } else if(lang==="kotlin"){ buildKotlin(zip,folder,app,_phCode,panelTxt); } else if(lang==="react"){ buildReact(zip,folder,app,_phCode,panelTxt); } else if(lang==="vue"){ buildVue(zip,folder,app,_phCode,panelTxt); } else if(lang==="angular"){ buildAngular(zip,folder,app,_phCode,panelTxt); } else if(lang==="python"){ buildPython(zip,folder,app,_phCode); } else if(lang==="node"){ buildNode(zip,folder,app,_phCode); } else { /* Document/content workflow */ var title=app.replace(/_/g," "); var md=_phAll||_phCode||panelTxt||"No content"; zip.file(folder+app+".md",md); var h=""+title+""; h+="

"+title+"

"; var hc=md.replace(/&/g,"&").replace(//g,">"); hc=hc.replace(/^### (.+)$/gm,"

$1

"); hc=hc.replace(/^## (.+)$/gm,"

$1

"); hc=hc.replace(/^# (.+)$/gm,"

$1

"); hc=hc.replace(/\*\*(.+?)\*\*/g,"$1"); hc=hc.replace(/\n{2,}/g,"

"); h+="

"+hc+"

Generated by PantheraHive BOS
"; zip.file(folder+app+".html",h); zip.file(folder+"README.md","# "+title+"\n\nGenerated by PantheraHive BOS.\n\nFiles:\n- "+app+".md (Markdown)\n- "+app+".html (styled HTML)\n"); } zip.generateAsync({type:"blob"}).then(function(blob){ var a=document.createElement("a"); a.href=URL.createObjectURL(blob); a.download=app+".zip"; a.click(); URL.revokeObjectURL(a.href); if(lbl)lbl.textContent="Download ZIP"; }); }; document.head.appendChild(sc); } function phShare(){navigator.clipboard.writeText(window.location.href).then(function(){var el=document.getElementById("ph-share-lbl");if(el){el.textContent="Link copied!";setTimeout(function(){el.textContent="Copy share link";},2500);}});}function phEmbed(){var runId=window.location.pathname.split("/").pop().replace(".html","");var embedUrl="https://pantherahive.com/embed/"+runId;var code='';navigator.clipboard.writeText(code).then(function(){var el=document.getElementById("ph-embed-lbl");if(el){el.textContent="Embed code copied!";setTimeout(function(){el.textContent="Get Embed Code";},2500);}});}