Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/Cascade.php
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,9 @@ private function isAvailableIn(string $locale): bool
&& (! $this->taxonomy->collection() || $this->taxonomy->collection()->sites()->contains($locale));
}

return $this->model->in($locale)?->status() === 'published';
$localization = $this->model->in($locale);

return $localization?->status() === 'published' && $localization->url();
}

private function absoluteUrlIn(SiteInstance $site): string
Expand Down
19 changes: 19 additions & 0 deletions tests/Localized/CascadeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Tests\Localized;

use PHPUnit\Framework\Attributes\Test;
use Statamic\Facades\Collection;
use Statamic\Facades\Config;
use Statamic\Facades\Entry;
use Statamic\SeoPro\Cascade;
Expand Down Expand Up @@ -45,6 +46,24 @@ public function it_reindexes_alternate_locales_after_filtering()
$this->assertSame('it', $data['alternate_locales'][0]['hreflang']);
}

/**
* @see https://github.com/statamic/seo-pro/issues/687
*/
#[Test]
public function it_excludes_alternate_locales_without_urls()
{
$collection = tap(Collection::make('snippets')->sites(['default', 'french']))->save();
$entry = tap(Entry::make()->collection($collection)->locale('default')->slug('banner'))->save();
$entry->makeLocalization('french')->save();

$data = (new Cascade)
->withSiteDefaults(SiteDefaults::in('default')->all())
->withCurrent($entry)
->get();

$this->assertEmpty($data['alternate_locales']);
}

#[Test]
public function it_generates_seo_cascade_for_canonical_url_and_handles_duplicate_alternate_hreflangs()
{
Expand Down
Loading