Kirby CMS Website Source

repository·main·Indexed 41 days ago

https://github.com/getkirby/getkirby.com

Source code and assets for the official getkirby.com website. Includes documentation for internal plugins such as the Discord plugin for sending webhooks via Discord::submit(), the Layouts plugin for HTML layouts and slots (requires Kirby 3.9.0+), the Meta plugin for SEO and social media metadata resolution, and the site plugin providing specialized field methods and helper functions.

Tokens
24.7K
Snippets
106
Records
135
Agent score
99%

What's inside Kirby

  1. Understand the Kirby Licensing Model

    main

    Kirby is not free software. While the source code is publicly available, using Kirby in a production environment (a Public Site) requires a paid license.

    Key concepts of the licensing model:

    • Per-Project Licensing: Each unique Website (defined by its domain name and root directory) requires its own license.
    • Website Definition: A Website is a single Kirby project. Subdomains or different root directories count as separate Websites.
      • Exception: If using the cross-domain multi-language feature with the same content folder, these domains count as the same Website.
      • Headless/SSG: If used as a headless backend or static site generator, the Website is defined by the domain/root of the visitor-facing frontend.
    • Included Updates Period: A license includes all Kirby releases (including Major Releases) published within three (3) years of the Activation Date.
    • Upgrading: To use Major Generations released after the three-year period, you must perform a paid license upgrade. Upgrading extends the update timeframe for another three years.
    • License Transfer/Reassignment: You can transfer a license to another person or reassign it to a different project for the same client, subject to verification and contact with support.
  2. Reuse MIT-licensed Source Code Parts

    main
    Certain parts of the Kirby Source Code are provided under the MIT license. You may use, copy, modify, merge, publish, distribute, sublicense, or sell these specific parts without restriction, provided that the copyright notice to Bastian Allgeier and the permission notice are included in all copies or substantial portions of the code.
  3. How Kirby\Reference\Types handles type representation

    main

    The Types namespace provides objects to represent and render PHP types in documentation.

    • Type: A simple type. Use $type->toString() for text or $type->toHtml() to wrap it in a <code> tag with the appropriate CSS selector. Use Type::factory() to instantiate.
    • Identifier: An extension of Type for classes. ::toHtml() can optionally link to the corresponding Reference page. This is used by Marsdown for inline code linking.
    • Chain: An extension of Type representing a chained method call (e.g., $page->content()->title()). It resolves the chain, provides links, and handles special short handles like $page.
    • Types: A collection of Type objects. It normalizes reflection data by:
      • Replacing self or static with full class names.
      • Removing duplicate types.
      • Including |null for nullable types. Use $types->toString() or $types->toHtml() for template rendering.
  4. Set and use URL parameters in Kirby

    main

    Kirby allows you to include human-readable parameters directly in the URL path using a key:value syntax. These parameters are ignored by the router, meaning they do not affect which page is matched, but they can be used to build URL-based filters for content.

    Syntax:

    • Linux/macOS: Use a colon (:) to separate the key and value: /path/key:value.
    • Windows: Use a semicolon (;) to separate the key and value: /path/key;value.

    To ensure cross-platform compatibility between Linux and Windows servers, always use the url() helper method with the params option instead of manually constructing strings.

    // Use this to generate cross-platform compatible URLs
    $url = url($path, ['params' => ['tag' => 'myTag']]);
  5. How the Kirby\Reference system works

    main

    The Kirby\Reference system uses PHP reflection to automatically generate documentation. It is built around the Reflectable abstraction.

    Reflectable Classes

    Various classes implement Reflectable to expose metadata about Kirby core components. Common classes include:

    • ReflectableFieldMethod (for field methods)
    • ReflectableKirbytag (for KirbyTags)
    • ReflectableClass and ReflectableClassMethod (for classes and methods)
    • ReflectableHelperFunction (for helper functions)
    • ReflectableCoreComponent (for core components)
    • ReflectableValidator (for validators)

    All Reflectable classes share a common set of methods to retrieve DocBlock information:

    • $reflectable->summary(): Short description from DocBlock.
    • $reflectable->examples(): Code examples from DocBlock.
    • $reflectable->isDeprecated(): Boolean indicating deprecation.
    • $reflectable->isInternal(): Boolean indicating if the part is internal.
    • $reflectable->since(): The @since tag information.
    • $reflectable->source(): URL to the GitHub source.
    • $reflectable->throws(): The @throws tag information.
  6. Determine if your installation requires a license

    main

    Kirby usage is categorized into three types. Whether you need to purchase a license depends on which category your installation falls into:

    Installation TypeDescriptionLicense Required
    Development InstallationInstalled purely for development and client preview. Must be restricted to a small number of users (e.g., local machine, private network, or password-protected staging).No (See Free Licenses section)
    Private InstallationInstalled purely for personal use. Must only be accessible by You and Your family.No (See Free Licenses section)
    Public SiteAny installation that is neither a Development nor a Private installation.Yes (Paid License Required)

    Note: Specific cases for free or discounted licenses may apply upon request.

  7. Review Kirby Warranty and Liability Terms

    main

    Kirby is provided on an "AS-IS" basis.

    • No Warranty: The developers expressly disclaim all warranties, including merchantability, fitness for a particular purpose, and non-infringement. Users assume all risks regarding quality, performance, installation, and potential data loss or program errors.
    • Limitation of Liability: The developers are not liable for direct, indirect, incidental, or consequential damages (such as loss of profits or data). In any event, total cumulative damages are limited to the fees paid to the developers in the most recent twelve-month period.
    • Indemnification: By using Kirby, you agree to indemnify and hold harmless the developers and their affiliates from any damages arising out of your use of the software.
  8. How the Meta plugin resolves metadata

    main

    The Meta plugin generates meta tags for search engines, social networks, and browsers by resolving data through a specific hierarchy. When looking for a metadata field, the plugin follows this order of precedence:

    1. Page Content File: It first checks the specific page's content file (e.g., article.txt).
    2. Page Model: If the field is missing from the content file, it checks if the page model provides a metadata() method that returns an array containing that data.
    3. Site Defaults: If neither of the above provides the field, it falls back to the default values defined in site.txt.

    All keys returned by a metadata() method in a page model must be lowercase.

  9. Modify Kirby Source Code for Extensions or Personal Use

    main

    You are permitted to alter, modify, or extend the Kirby Source Code for your own use or to contribute changes back to the project. You may also commission third parties to perform these modifications.

    Restrictions on modification:

    • Do not alter or circumvent licensing features (e.g., license validation, development license activation, renewal, or payment prompts).
    • Do not remove or alter any proprietary notices.
    • Do not resell, redistribute, or transfer modified or derivative versions.

    Note: Technical support is not provided for modified or derivative versions of the Source Code.

  10. How Kirby Layouts and slots work

    main

    The plugin extends Kirby's snippet system by allowing you to store full HTML layouts in /site/layouts.

    Layouts and Slots

    Layouts use slots to define where content from a template should be injected.

    • The Default Slot: Represented by the variable $slot. If you do not specify a name for a slot in your template, the content is passed to this default slot.
    • Named Slots: You can define multiple unique named slots in a layout. These allow you to inject content into specific parts of the layout (e.g., a sidebar or a header) from your template.
    • Default Content: Slots in layouts can define default content that renders if the template does not provide content for that specific slot.

    Implementation Example

    1. Define the layout in /site/layouts/default.php:

    <html
    	<head>
    		<title><?= $page->title() ?></title>
    	</head>
    	<body>
    		<?= $slot ?>
    	</body>
    </html>

    2. Use the layout in /site/templates/my-template.php:

    <?php layout() ?>
    
    <h1 >Hello world</h1>
    <p>This will end up in the default slot</p>
    <!-- /site/layouts/default.php -->
    <html
    	<head>
    		<title><?= $page->title() ?></title>
    	</head>
    	<body>
    		<?= $slot ?>
    	</body>
    </html>
    
    <!-- /site/templates/my-template.php -->
    <?php layout() ?>
    
    <h1 >Hello world</h1>
    <p>This will end up in the default slot</p>
  11. Understand the Kirby License and Maintenance Policy

    main

    Kirby is a proprietary software product owned by Bastian Allgeier. Use of the software is governed by the Kirby License Agreement.

    Maintenance and Open Source Transition: If Kirby is not actively maintained (defined as no stable release being published for a period of 365 days), the Source Code in its last published form automatically transitions to the MIT License. This allows users to use, copy, modify, and distribute the code under MIT terms, provided the original copyright notice to Bastian Allgeier is included.

    Support and Custom Licensing: For special use cases or requirements that do not fit the standard agreement, you can contact the Kirby team for custom license solutions at support@getkirby.com.

  12. How Kirby\Marsdown works

    main

    The Kirby\Marsdown component is a superset of ParsedownExtra. It is used to parse Markdown with advanced features including:

    • Groupings: Support for columns and tabs.
    • Blocks: Support for info blocks or 'since' blocks.
    • Fenced Codeblocks: Enhanced support for Kirby content files and filesystem figures.
    • Inline Type Highlighting: Automatic highlighting and linking for types (where available).