Closed tao closed 4 years ago
Named profiles can also be used to generate a specific part of the site, which may be useful for testing or syncing a large site. For example, in my use-case I only want to re-generate news when it's updated instead of re-generating all 8000 pages on my site (which takes 4 hours), and using the Amazon s3 sync command allows me to sync only these new files without removing the older content.
'profiles' => [
'news' => [
'/',
'/news',
'/news/feed',
'/news/updates',
],
'about' => [
'/about',
'/about/history',
],
],
You can then call the commands:
php please ssg:generate --profile=news
php please ssg:generate --profile=about
This may also be useful for testing, if you want to generate a group of static pages only.
When using named profiles, the new excludes
option is set to ignore all pages so that only the specifically defined pages in the profile routes + any routes in the config['urls'] are used. When no profile is set, then the site is generated as usual with a fallback default
profile.
You can now also define a group of pages in a profile using wildcards:
'profiles' => [
'news' => [
'/',
'/news',
'/news/*',
'/rss',
],
],
This will generate all news pages and articles, such as:
[✔] /
[✔] /about
[✔] /news
[✔] /news/a-new-journey
[✔] /news/feed
[✔] /news/updates
[✔] /news/the-crop-circle-mystery
[✔] /news/fun-with-static-site-generators
[✔] /rss
In this example, /about
was included from the standard config.urls
array.
I'm also being verbose by including /news
and /news/*
in the profile array but you can also use a more concise version of the news routes:
'profiles' => [
'news' => [
'/',
'/news*',
'/rss',
],
],
I found this useful for testing SSG with lots of content, this allows you to exclude certain routes with wildcards to make the build faster.
In the
statamic/ssg.php
config you can use wildcards as follows: