Next.js: Pretty Static Export Paths

Created on 12 Sep 2017  路  7Comments  路  Source: vercel/next.js

Is there any way to trim the / off of the static export output? Many static hosts like GH pages and Netlify support trimming the .html off of your paths for "pretty" URL paths.

But it looks like static export turns all of your /path/links to /path/links/. It'd be nice if there was an option to turn on pretty URL paths for exporting to the static hosts that support them.

Most helpful comment

It is only solved for now deployments. It鈥檚 not solved for general exports.

All 7 comments

Can not be omitted "/". Could you give me an example of what you are saying about the routes.

So basically, in my next.config.js file, I've got a route specified as /path/product. Whenever I export, the path becomes /path/product/ in all .html files.

But most static hosts actually do support the /path/product link without the trailing slash. So I was wondering if it'd be possible to provide a CLI option to next export that would not rewrite the URLs to have trailing slashes.

@kennedyrose sounds like a job for custom routes:

https://github.com/zeit/next.js/blob/master/examples/with-next-routes/routes.js

Although if you're already doing that, then express has an optional param you can pass in called strict for strict routing.

screen shot 2017-09-22 at 11 35 10 pm

Maybe that'll do it?

@pruhstal @kennedyrose There's a wiki article for that:tm: https://github.com/zeit/next.js/wiki/Centralizing-Routing

Edit: thought this was a different issue 馃槄

@pruhstal this is specifically directed a next export so you can't use a custom server 馃憤

@kennedyrose seems like a reasonable request, I'll put it on the backlog 馃憤

It is only solved for now deployments. It鈥檚 not solved for general exports.

@mrcoles Seems you are right. Hopefully this can be addressed someday :man_shrugging:

Was this page helpful?
0 / 5 - 0 ratings

Related issues

renatorib picture renatorib  路  3Comments

olifante picture olifante  路  3Comments

swrdfish picture swrdfish  路  3Comments

havefive picture havefive  路  3Comments

YarivGilad picture YarivGilad  路  3Comments