angular / angular/angular-cli

SSG/Prerendering: Allow generating foo.html instead of foo/index.html

Aperta
#29,173 5 commenti 16 reazioni 0 assegnatari Vedi su GitHub
angular/build:application area: @angular/build area: @angular/ssr feature feature: insufficient votes
Lingua principale
TypeScript
Stelle
27k
Fork
11.8k
Merge medio
14h 23m
PR unite (30g)
162

Descrizione

### Description

Angular's Prerendering puts nested routes into a subfolder with `index.html`:
*=> Route `blog/myslug` becomes `blog/myslug/index.html`*

**The web server adds a trailing slash (for the folder) which is then removed by the Angular router, and it leads to an initial redirect.**

### Describe the solution you'd like

Some static site generators allow to create a flat structure instead with no subfolder:
*=> Route `blog/myslug` becomes `blog/myslug.html`*

**Proposed solution:**
- Output `myslug/index.html` by default, it is the most compatible output that works on each and every web server
- add an option for flat output (`myslug.html`) that can be used if I know my web server supports this

### Context

- Jekyll always outputs `myslug.html`
- [Nuxt v2 has an option](https://nuxt.com/deploy/cloudflare#route-matching)
- [Next.js has an option](https://nextjs.org/docs/app/api-reference/config/next-config-js/trailingSlash)

Most cloud hosting providers allow to serve `myslug.html` under `myslug`:
- GitHub Pages
- Cloudflare Pages
- [Firebase Hosting](https://firebase.google.com/docs/hosting/full-config#control_html_extensions)
- [Vercel](https://vercel.com/docs/projects/project-configuration#cleanurls)
- [Netlify](https://docs.netlify.com/routing/redirects/redirect-options/#trailing-slash)

Further read on trailing slash and framework/provider support: https://bjornlu.com/blog/trailing-slash-for-frameworks

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

Inizia dal punto di ingresso del prerendering di Angular CLI ed esamina i test esistenti per l’output delle route annidate. Conferma il layout attuale di index.html, quindi definisci e verifica un’opzione che produca un layout piatto di route.html, mantenendo il comportamento predefinito.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
angular, typescript
Ambito
build-system
Tipo di issue
Funzionalità
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
42/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.