Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feat] add prerender.createIndexFiles option #2632

Merged

Conversation

bfanger
Copy link
Contributor

@bfanger bfanger commented Oct 18, 2021

Fixes #1443

Usage in svelte.config:

kit: {
  prerender: {
    subfolders: false,
  },
   ...

Setting the kit.prerender.subfolders setting to false (default is true) will change the filename generation from "/about/index.html" to "/about.html"

Inspiration for the subfolders name came from nuxt:
https://nuxtjs.org/docs/configuration-glossary/configuration-generate/#subfolders

@changeset-bot
Copy link

changeset-bot bot commented Oct 18, 2021

🦋 Changeset detected

Latest commit: 8504a47

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@sveltejs/kit Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@benmccann benmccann added the feature request New feature or request label Oct 18, 2021
- Fixes sveltejs#1443

Setting the kit.prerender.subfolders to false (default is true) will change the filename generation from "/about/index.html" to "/about.html"
@netlify
Copy link

netlify bot commented Jan 16, 2022

✔️ Deploy Preview for kit-demo ready!

🔨 Explore the source changes: 8504a47

🔍 Inspect the deploy log: https://app.netlify.com/sites/kit-demo/deploys/61f48bebde7586000722dc17

😎 Browse the preview: https://deploy-preview-2632--kit-demo.netlify.app

@vercel
Copy link

vercel bot commented Jan 27, 2022

@Rich-Harris is attempting to deploy a commit to the Svelte Team on Vercel.

A member of the Team first needs to authorize it.

@Rich-Harris
Copy link
Member

Thank you, and apologies for not getting round to this PR until now. One thing I'm not 100% sure about is the subfolders name — something about it feels a little non-descriptive. What about something like createIndexFiles?

@bfanger
Copy link
Contributor Author

bfanger commented Jan 28, 2022

Apology is appreciated.
I agree that the naming could be better, but don't think createIndexFiles is it, that name makes sense from the kit codebase standpoint, but from a user perspective it's about is not generating folders, the index files are a byproduct..

if we change the config from a boolean to an enum, that show the intent better:

routeOutput: 'file' | 'folder'

What do you think?

@Rich-Harris
Copy link
Member

I think a boolean makes more sense to be honest. We discussed in the maintainers chatroom and decided to go with createIndexFiles — it's the sort of thing that's easy to find in the docs when you start looking for information about index.html

@Rich-Harris Rich-Harris merged commit 707e23d into sveltejs:master Jan 29, 2022
@ignatiusmb ignatiusmb mentioned this pull request Jan 29, 2022
5 tasks
@ignatiusmb ignatiusmb changed the title [feat] add prerender.subfolders setting [feat] add prerender.createIndexFiles option Jan 29, 2022
@isapir
Copy link

isapir commented Mar 24, 2023

Is kit.prerender.subfolders: false still a thing?

I get an error:

Error: Unexpected option config.kit.prerender.subfolders

I have this in svelte.config.js:

/**
 * from https://kit.svelte.dev/docs/adapter-static
 */
import adapter from '@sveltejs/adapter-static';

export default {
	kit: {
		adapter: adapter({
			// default options are shown. On some platforms
			// these options are set automatically — see below
			pages: 'build',
			assets: 'build',
			fallback: null,
			precompress: false,
			strict: true
		}),
		prerender: {
			subfolders: false,
		},
	}
};

@bfanger
Copy link
Contributor Author

bfanger commented Mar 25, 2023

// src/routes/+layout.js
export const trailingSlash = 'always';

https://kit.svelte.dev/docs/page-options#trailingslash

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Ability to prerender to about.html instead of about/index.html like Sapper
4 participants