bnomei/kirby3-htmlhead

Kirby Plugin for a best-practice HTML Head Element extendable with snippets.

Installs: 3 394

Dependents: 0

Suggesters: 1

Security: 0

Stars: 20

Watchers: 1

Forks: 0

Open Issues: 1

Type:kirby-plugin

5.0.1 2024-11-30 09:56 UTC

README

Kirby 5 PHP 8.2 Release Downloads Coverage Maintainability Discord Buymecoffee

Kirby Plugin for a best-practice HTML Head Element extendable with snippets.

Installation

  • unzip master.zip as folder site/plugins/kirby3-htmlhead or
  • git submodule add https://github.com/bnomei/kirby3-htmlhead.git site/plugins/kirby3-htmlhead or
  • composer require bnomei/kirby3-htmlhead

Usage

Use the htmlhead() helper to add meta tags, link tags, script tags, etc. to the head of your HTML document. The helper performs a little bit of magic and is actually calling regular Kirby snippets. This way, you can mix and match the helper with your own snippets.

Tip

The order of the tags in the code example is based on best practices. You might want to stick to it as closely as possible and append your own at the end.

<!DOCTYPE html>
<html>
    <head>
        <?= htmlhead()
            ->recommended_minimum()
            ->title()
            ->base()
            // ->link_preconnect(...)
            ->script_js(['/assets/app-async.js'], async: true)
            ->script_js(['/assets/app.js'])
            ->link_css(['/assets/app.css'])
            // ->link_a11ycss()
            // ->link_csswizardry_ct()
            // ->link_preload(...)
            // ->script_js(['/assets/app-defer.js'], defer: true)
            // ->link_prefetch(...)
            // ->link_prerender(...)
            // ->link_canonical(...)
            // ->link_alternates(...)
            ->meta_robots()
            ->meta_author(site()->author())
            ->meta_description($page->seoDesc())
            ->meta_opengraph(description: $page->seoDesc())
            ->link_feedrss()
            // site/snippets/my-snippet.php
            ->my_snippet(['key' => 'value'])
        ?>
    </head>
    <body>
        <!-- ... -->
    </body>
</html>

Resources

Disclaimer

This plugin is provided "as is" with no guarantee. Use it at your own risk and always test it yourself before using it in a production environment. If you find any issues, please create a new issue.

License

MIT

It is discouraged to use this plugin in any project that promotes racism, sexism, homophobia, animal abuse, violence or any other form of hate speech.