SEO

General

General

How do I add SEO Metadata to a page?

You can use the \Aero\Marketing\Facades\SearchOptimization facade to add SEO Metadata to a page.

See below an example of how we do it for \Aero\Store\Http\Responses\Homepage & Aero\Store\Http\Responses\InformationPage by adding the Aero\Store\Http\Responses\Steps\Page\AttachMetaData step:

class AttachMetaData
{
    public function handle(\Aero\Responses\ResponseBuilder $builder, \Closure $next)
    {
        /** @var $page \Aero\Content\Models\Page */
        $page = $builder->page;

        if (! $page->key) {
            \Aero\Marketing\Facades\SearchOptimization::setTitle($page->name);
        }

        if ($page->seo) {
            \Aero\Marketing\Facades\SearchOptimization::setCanonical($page->getCanonical());

            if (! empty($page->seo->page_title)) {
                \Aero\Marketing\Facades\SearchOptimization::setTitle($page->seo->page_title, false);
            }

            if ($page->seo->noindex) {
                \Aero\Marketing\Facades\SearchOptimization::setNoIndex();
            }

            if ($page->seo->nofollow) {
                \Aero\Marketing\Facades\SearchOptimization::setNoFollow();
            }
        }

        \Aero\Marketing\Facades\SearchOptimization::setDescription($page->getMetaDescription());

        \Aero\Marketing\Facades\OpenGraph::withPage($page);

        return $next($builder);
    }
}

Methods

Method
Description
setTitle($title, $appendDefault = true) Sets the page title, optionally appending the configured default title postfix.
setDescription(string $description) Sets the page meta description.
setCanonical($canonical) Sets the canonical URL for the page.
setAmpHtml(string $url) Sets the AMP HTML URL.
addAlternativeLanguage(string $lang, string $url) Adds an alternate-language URL with its hreflang language code.
addAlternativeLanguages(array $languages) Adds multiple alternate-language URLs.
setNoIndex(bool $index = true) Enables or disables the noindex robots directive.
setNoFollow(bool $follow = true) Enables or disables the nofollow robots directive.
setRobotContent(?string $content) Sets custom robots meta content.
setNext(LengthAwarePaginator $listings) Sets the next-page URL for paginated content.
setPrev(LengthAwarePaginator $listings) Sets the previous-page URL for paginated content.

Robots Txt

Robots Txt

How do I modify robots.txt?

You can modify the robots.txt file by extending the \Aero\Store\Pipelines\RobotsTxt pipeline.

For example, you can prevent search engines from crawling the admin login page:

\Aero\Store\Pipelines\RobotsTxt::extend(function (\Aero\Store\Collections\RobotsTxtCollection $content, \Closure $next) {
    $adminSlug = config('aero.admin.slug');

    $content->agent('*')->disallow("/{$adminSlug}");

    return $next($content);
});

Parameters

Parameter Type Description
$content \Aero\Store\Collections\RobotsTxtCollection The collection of rules for the robots.txt file.
$next \Closure The next step in the pipeline.

Methods

Method Description
agent(string $agent) Gets or creates a new rule collection for the specified user agent.
removeAgent(string $agent) Removes a user agent entirely (including all of its defined rules).
allow(string $value)
Adds an Allow: $value rule.
removeAllow(string $value)
Removes an Allow: $value rule.
disallow(string $value)
Adds an Disallow: $value rule.
removeDisallow(string $value)
Removes an Disallow: $value rule.
sitemap(string $value)
Adds an Sitemap: $value rule.
removeSitemap(string $value)
Removes an Sitemap: $value rule.
crawlDelay(string $value)
Adds an Crawl-delay: $value rule.
removeCrawlDelay(string $value)
Removes an Crawl-delay: $value rule.
requestRate(string $value)
Adds an Request-rate: $value rule.
removeRequestRate(string $value)
Removes an Request-rate: $value rule.