Static Site Generation Config
Static site generation is created from the built in adapter, to create an adapter run:
npm run qwik add
Adaptor: Static site (.html files). Done!
Running the above command will make the following changes to your project:
build.serverscript will be automatically added to your
adaptors/vite.config.tsfile will be created.
In node you can run the generation after building using:
Your build files will be generated into the
adaptors/vite.config.ts file also includes the SSG config, which would be custom for each implementation.
origin, which is a combination of the scheme (protocol) and hostname (domain). For example,
https://qwik.builder.io has the protocol
https:// and domain
qwik.builder.io. However, the
origin does not include a
origin is used to provide a full URL during Static Site Generation (SSG), and to simulate a complete URL rather than just the
pathname. For example, in order to render a correct canonical tag URL or URLs within the
origin must be provided too.
If the site also starts with a pathname other than
/, please use the
basePathname option in the Qwik City config options.
outDir is a file system output directory where the static files should be written. In the example above, it's using Node's fileURLToPath to create an absolute file system path to write the static HTML files to.
qwikCityGenerate() function is imported from
@builder.io/qwik-city/static/node. By scoping the generate function to a specific runtime, such as Node.js, this gives Qwik City the flexibility to also generate SSG from other runtimes in the future, such as Deno or Bun.