#Changing Routes on Every Build

1 messages · Page 1 of 1 (latest)

vale warren
#

Is there a way to randomize all page routes when building?

So instead of home.astro -> /home

home.astro -> /n0smtj or something like that

carmine sageBOT
#

Hi @vale warren. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:

#

Astro’s routing is based on the file structure inside the src/pages/ directory, and by default, each file’s route is determined by its filename and path. There is no built-in feature or documented method in the official Astro documentation to randomize or obfuscate all page routes on every build, such as mapping home.astro to a random string like /n0smtj each time you build your site.

Dynamic routes in Astro (using [param].astro or [...param].astro) allow you to generate multiple pages with different parameters, but the mapping between parameters and routes is determined by your implementation of getStaticPaths() and is typically based on your data, not randomized per build. There is also no mention of a plugin or integration that would automate randomizing all routes on each build in the provided knowledge sources.

If you need to customize output file names for assets (like JS or CSS), you can do so by customizing Rollup output options, but this does not apply to page routes themselves Customize file names in the build output.

In summary, the knowledge sources do not contain information about a supported or recommended way to randomize all page routes on every build in Astro.

Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: