Skip to main content

News and magazine

Editorial sites live and die by their URLs: headlines get rewritten, articles get translated, and every published link has to keep working.

#[Polyslug(source: 'headline', unicode: 'native')] // keep non-Latin headlines intact
class Article extends Model implements Sluggable
{
use HasPolyslug;
}

$article->setSlug('de', 'Schlagzeile');
$article->hreflangTags($resolver); // reciprocal hreflang from the same resolver as the canonical URL
// php artisan polyslug:sitemap --path=public/sitemap.xml
  • unicode: 'native' keeps Cyrillic, Greek, Chinese or accented Latin headlines readable in the URL instead of transliterating them into something nobody searches for.
  • setSlug($locale, …) stores one slug per language; the article keeps a single identity across all of them.
  • hreflangTags() builds the reciprocal set from the same resolver as the canonical URL, so the two cannot drift apart — the usual cause of the wrong language ranking.
  • polyslug:sitemap emits the same alternates inside each <url> entry.

Rewriting a headline supersedes the old slug and 301s every published link, so a correction after publication costs no traffic.

Keep drafts out

Add polyslugIsRoutable() so unpublished articles never appear in the sitemap or an hreflang set, and polyslugResolveQuery() if a draft URL must not resolve at all.

See also