Skip to content

Commit

Permalink
Skip sitemap generation when there is no valid base URL
Browse files Browse the repository at this point in the history
Before, this would fall back to a relative URL, but these no longer validate by Google and will not be indexed. It feels a bit dramatic to have an exception be thrown when building test sites locally so instead we just skip the build, but with a helpful message.
  • Loading branch information
caendesilva committed Apr 13, 2024
1 parent 3189eb3 commit 4f85baf
Showing 1 changed file with 4 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ class GenerateSitemap extends PostBuildTask

public function handle(): void
{
if (blank(Hyde::url()) || str_starts_with(Hyde::url(), 'http://localhost')) {
$this->skip('Cannot generate sitemap without a valid base URL');
}

$this->path = Hyde::sitePath('sitemap.xml');

$this->needsParentDirectory($this->path);
Expand Down

0 comments on commit 4f85baf

Please sign in to comment.