{"id":18369954,"url":"https://github.com/statamic/ssg","last_synced_at":"2025-04-13T07:49:02.615Z","repository":{"id":38364103,"uuid":"227918331","full_name":"statamic/ssg","owner":"statamic","description":"The official Statamic Static Site Generator","archived":false,"fork":false,"pushed_at":"2025-03-04T15:39:54.000Z","size":108,"stargazers_count":248,"open_issues_count":36,"forks_count":25,"subscribers_count":12,"default_branch":"3.x","last_synced_at":"2025-04-04T05:44:19.868Z","etag":null,"topics":["hacktoberfest","laravel","ssg","statamic","statamic-4","statamic-v3","static-site-generator"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/statamic.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-12-13T20:38:22.000Z","updated_at":"2025-03-20T12:50:10.000Z","dependencies_parsed_at":"2024-02-29T17:32:38.294Z","dependency_job_id":"9de38c49-a988-4400-b270-258902c37534","html_url":"https://github.com/statamic/ssg","commit_stats":{"total_commits":92,"total_committers":17,"mean_commits":5.411764705882353,"dds":0.4565217391304348,"last_synced_commit":"ee7934f6ddbf974d75320d8b8bb50535d40de63f"},"previous_names":[],"tags_count":22,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/statamic%2Fssg","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/statamic%2Fssg/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/statamic%2Fssg/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/statamic%2Fssg/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/statamic","download_url":"https://codeload.github.com/statamic/ssg/tar.gz/refs/heads/3.x","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248681494,"owners_count":21144700,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["hacktoberfest","laravel","ssg","statamic","statamic-4","statamic-v3","static-site-generator"],"created_at":"2024-11-05T23:34:33.510Z","updated_at":"2025-04-13T07:49:02.584Z","avatar_url":"https://github.com/statamic.png","language":"PHP","readme":"# Statamic Static Site Generator\n\n\u003c!-- statamic:hide --\u003e\n\n\u003e Generate static sites with Statamic.\n\n\u003c!-- /statamic:hide --\u003e\n\n## Installation\n\nYou can install the Static Site Generator package with the following command:\n\n```\nphp please install:ssg\n```\n\nThe command will install the `statamic/ssg` package via Composer, optionally publish the configuration file and prompt you if you wish to install the `spatie/fork` package for running [multiple workers](#multiple-workers).\n\n\n## Usage\n\nRun the following command:\n\n```\nphp please ssg:generate\n```\n\nYour site will be generated into a directory which you can deploy however you like. See [Deployment Examples](#deployment-examples) below for inspiration.\n\n\n### Multiple Workers\n\nFor improved performance, you may spread the page generation across multiple workers. This requires Spatie's [Fork](https://github.com/spatie/fork) package. Then you may specify how many workers are to be used. You can use as many workers as you have CPU cores.\n\n```\ncomposer require spatie/fork\nphp please ssg:generate --workers=4\n```\n\n\n## Routes\n\nRoutes will not automatically be generated. You can add any additional URLs you wish to be generated by adding them to the `urls` array in the config file.\n\n``` php\n'urls' =\u003e [\n    '/this-route',\n    '/that-route',\n],\n```\n\nYou can also exclude single routes, or route groups with wildcards. This will override anything in the `urls` config.\n\n``` php\n'exclude' =\u003e [\n    '/secret-page',\n    '/cheat-codes/*',\n],\n```\n\n### Dynamic Routes\n\nYou may add URLs dynamically by providing a closure that returns an array to the `addUrls` method.\n\n```php\nuse Statamic\\StaticSite\\SSG;\n\nclass AppServiceProvider extends Provider\n{\n    public function boot()\n    {\n        SSG::addUrls(function () {\n            return ['/one', '/two'];\n        });\n    }\n}\n```\n\n### Pagination Routes\n\nWherever pagination is detected in your antlers templates (eg. if you use the `paginate` param on the `collection` tag), multiple pages will automatically be generated with `/articles/page/2` style urls.\n\nYou may configure a custom routing style in `config/statamic/ssg.php`:\n\n```php\n'pagination_route' =\u003e '{url}/{page_name}/{page_number}',\n```\n\n\n## Post-generation callback\n\nYou may optionally define extra steps to be executed after the site has been generated.\n\n``` php\nuse Statamic\\StaticSite\\SSG;\n\nclass AppServiceProvider extends Provider\n{\n    public function boot()\n    {\n        SSG::after(function () {\n            // eg. copy directory to some server\n        });\n    }\n}\n```\n\n\n## Glide Images\n\nThe default configuration of Statamic is to have Glide use \"dynamic\" images, which means that the `glide` tag will only output URLs. The images themselves will be generated when the URLs are visited. For a static site, this no longer makes sense since it will typically be deployed somewhere where there is no dynamic Glide route available.\n\nBy default, the SSG will automatically reconfigure Glide to generate images into the `img` directory whenever `glide` tags are used. This is essentially Glide's [custom static path option](https://statamic.dev/image-manipulation#custom-path-static).\n\nYou can customize where the images will be generated:\n\n```php\n'glide' =\u003e [\n    'directory' =\u003e 'images',\n],\n```\n\nIf you are using a [custom glide disk](https://statamic.dev/image-manipulation#custom-disk-cdn), you can tell the SSG to leave it alone:\n\n```php\n'glide' =\u003e [\n    'override' =\u003e false,\n],\n```\n\nAnd then copy the images over (or create a symlink) after generating has completed:\n\n```php\nSSG::after(function () {\n    $from = public_path('img');\n    $to = config('statamic.ssg.destination').'/img';\n\n    app('files')-\u003ecopyDirectory($from, $to);\n    // or\n    app('files')-\u003elink($from, $to);\n});\n```\n\n## Triggering Command Failures\n\nIf you are using the SSG in a CI environment, you may want to prevent the command from succeeding if any pages aren't generated (e.g. to prevent deployment of an incomplete site).\n\nBy default, the command will finish and exit with a success code even if there were un-generated pages. You can tell configure the SSG to fail early on errors, or even on warnings.\n\n```php\n'failures' =\u003e 'errors', // or 'warnings'\n```\n\n\n## Deployment Examples\n\nThese examples assume your workflow will be to author content **locally** and _not_ using the control panel in production.\n\n### Deploy to [Netlify](https://netlify.com)\n\nDeployments are triggered by committing to Git and pushing to GitHub.\n\n- Create a site in your [Netlify](https://netlify.com) account\n- Link the site to your desired GitHub repository\n- Set build command to `php please ssg:generate`\n    - If you need to compile css/js, be sure to add that command too and execute it before generating the static site folder\n    - ie. `npm install \u0026\u0026 npm run build \u0026\u0026 php please ssg:generate`\n- Set publish directory to `storage/app/static`\n- Add `APP_KEY` env variable, by running `php artisan key:generate` locally, and copying from your `.env`\n    - ie. `APP_KEY` `your-app-key-value`\n- Add `APP_URL` environment variable after your site has a configured domain\n    - ie. `APP_URL` `https://thats-numberwang-47392.netlify.com`\n\n#### S3 Asset Containers\n\nIf you are storing your assets in an S3 bucket, the `.env`s used will need to be different to the defaults that come with Laravel, as they are reserved by Netlify. For example, you can amend them to the following:\n\n```sh\n# .env\nAWS_S3_ACCESS_KEY_ID=\nAWS_S3_SECRET_ACCESS_KEY=\nAWS_S3_DEFAULT_REGION=\nAWS_S3_BUCKET=\nAWS_URL=\n```\n\nBe sure to also update these in your `s3` disk configuration:\n\n```php\n// config/filesystems.php\n's3' =\u003e [\n    'driver' =\u003e 's3',\n    'key' =\u003e env('AWS_S3_ACCESS_KEY_ID'),\n    'secret' =\u003e env('AWS_S3_SECRET_ACCESS_KEY'),\n    'region' =\u003e env('AWS_S3_DEFAULT_REGION'),\n    'bucket' =\u003e env('AWS_S3_BUCKET'),\n    'url' =\u003e env('AWS_URL'),\n],\n```\n\n### Deploy to [Vercel](https://vercel.com)\n\nDeployments are triggered by committing to Git and pushing to GitHub.\n\n- Create a new file `build.sh` file in your project and paste from the [example code snippet](#example-build-script) below\n- Run `chmod +x build.sh` on your terminal to make sure the file can be executed when deploying\n- Import a new site in your [Vercel](https://vercel.com) account\n- Link the site to your desired GitHub repository\n- Set build command to `./build.sh`\n- Set output directory to `storage/app/static`\n- Add `APP_KEY` env variable, by running `php artisan key:generate` locally, and copying from your `.env`\n    - ie. `APP_KEY` `your-app-key-value`\n- Add `APP_URL` environment variable after your site has a configured domain\n    - ie. `APP_URL` `https://thats-numberwang-47392.vercel.app`\n\n#### Example Build Script\n\nAdd the following snippet to `build.sh` file to install PHP, Composer, and run the `ssg:generate` command:\n\n```\n#!/bin/sh\n\n# Install PHP \u0026 WGET\ndnf clean metadata\ndnf install -y php8.2 php8.2-{common,mbstring,gd,bcmath,xml,fpm,intl,zip}\ndnf install -y wget\n\n# INSTALL COMPOSER\nEXPECTED_CHECKSUM=\"$(wget -q -O - https://composer.github.io/installer.sig)\"\nphp -r \"copy('https://getcomposer.org/installer', 'composer-setup.php');\"\nACTUAL_CHECKSUM=\"$(php -r \"echo hash_file('sha384', 'composer-setup.php');\")\"\n\nif [ \"$EXPECTED_CHECKSUM\" != \"$ACTUAL_CHECKSUM\" ]\nthen\n    \u003e\u00262 echo 'ERROR: Invalid installer checksum'\n    rm composer-setup.php\n    exit 1\nfi\n\nphp composer-setup.php --quiet\nrm composer-setup.php\n\n# INSTALL COMPOSER DEPENDENCIES\nphp composer.phar install\n\n# GENERATE APP KEY\nphp artisan key:generate\n\n# BUILD STATIC SITE\nphp please stache:warm -n -q\nphp please ssg:generate\n```\n\n\n### Deploy to [Surge](https://surge.sh)\n\n**Prerequisite:** Install with `npm install --global surge`. Your first deployment will involve creating an account via command line.\n\n- Build with command `php please ssg:generate`\n- Deploy with `surge storage/app/static`\n\n### Deploy to [Firebase hosting](https://firebase.google.com/products/hosting/)\n\n**Prerequisite:** Follow the instructions to [get started with Firebase hosting](https://firebase.google.com/docs/hosting/quickstart)\n\n- Once hosting is set up, make sure the `public` config in your `firebase.json` is set to `storage/app/static`\n- (Optionally) Add a `predeploy` config to run `php please ssg:generate`\n- Run `firebase deploy`\n","funding_links":[],"categories":["PHP"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstatamic%2Fssg","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstatamic%2Fssg","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstatamic%2Fssg/lists"}