Skip to content

Commit 7fcf563

Browse files
authored
Merge pull request #1660 from hydephp/skip-sitemap-generations-when-setup-is-invalid
Skip sitemap generation when there is no valid base URL
2 parents 27d01d4 + 20f5002 commit 7fcf563

File tree

3 files changed

+7
-0
lines changed

3 files changed

+7
-0
lines changed

RELEASE_NOTES.md

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ This serves two purposes:
1818

1919
### Changed
2020
- The `features` array in the `config/hyde.php` configuration file is now an array of `Feature` enums in https://github.com/hydephp/develop/pull/1650
21+
- Sitemap generation will now be skipped if a base URL is not set, as Google now will not index sitemaps without a base URL in https://github.com/hydephp/develop/pull/1660
2122

2223
### Deprecated
2324
- Deprecated the static `Features` flag methods used in the configuration files in https://github.com/hydephp/develop/pull/1650 and will be removed in HydePHP v2.0

packages/framework/src/Framework/Actions/PostBuildTasks/GenerateSitemap.php

+4
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ class GenerateSitemap extends PostBuildTask
2121

2222
public function handle(): void
2323
{
24+
if (blank(Hyde::url()) || str_starts_with(Hyde::url(), 'http://localhost')) {
25+
$this->skip('Cannot generate sitemap without a valid base URL');
26+
}
27+
2428
$this->path = Hyde::sitePath('sitemap.xml');
2529

2630
$this->needsParentDirectory($this->path);

packages/framework/tests/Feature/Services/BuildTaskServiceTest.php

+2
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ class BuildTaskServiceTest extends TestCase
3030
*/
3131
public function testBuildCommandCanRunBuildTasks()
3232
{
33+
config(['hyde.url' => 'https://example.com']);
34+
3335
$this->artisan('build')
3436
->expectsOutputToContain('Removing all files from build directory')
3537
->expectsOutputToContain('Generating sitemap')

0 commit comments

Comments
 (0)