Getting Started
Understanding Prezet's Configuration File
The configuration file is published as part of the package's installation command, but you can manually publish or re-publish it at any time by running:
1php artisan vendor:publish --provider="BenBjurstrom\Prezet\PrezetServiceProvider" --tag=prezet-config
After installation or re-publication, the config/prezet.php
file will look like this:
1<?php 2 3return [ 4 /* 5 |-------------------------------------------------------------------------- 6 | Filesystem Configuration 7 |-------------------------------------------------------------------------- 8 | 9 | This setting determines the filesystem disk used by Prezet to store and 10 | retrieve markdown files and images. By default, it uses the 'prezet' disk. 11 | 12 */ 13 14 'filesystem' => [ 15 'disk' => env('PREZET_FILESYSTEM_DISK', 'prezet'), 16 ], 17 18 /* 19 |-------------------------------------------------------------------------- 20 | Slug Configuration 21 |-------------------------------------------------------------------------- 22 | 23 | Configure how document slugs are generated. The source can be 'filepath' 24 | or 'title'. Note that a slug defined in front matter will take precedence 25 | over the generated slug. When 'keyed' is true, the key present in the 26 | front matter key will be appended to the slug (e.g., my-post-123). 27 | 28 */ 29 30 'slug' => [ 31 'source' => 'filepath', // 'filepath' or 'title' 32 'keyed' => false, // 'true' or 'false' 33 ], 34 35 /* 36 |-------------------------------------------------------------------------- 37 | CommonMark 38 |-------------------------------------------------------------------------- 39 | 40 | Configure the CommonMark Markdown parser. You can specify the extensions 41 | to be used and their configuration. Extensions are added in the order 42 | they are listed. 43 | 44 */ 45 46 'commonmark' => [ 47 48 'extensions' => [ 49 League\CommonMark\Extension\CommonMark\CommonMarkCoreExtension::class, 50 League\CommonMark\Extension\HeadingPermalink\HeadingPermalinkExtension::class, 51 League\CommonMark\Extension\ExternalLink\ExternalLinkExtension::class, 52 League\CommonMark\Extension\FrontMatter\FrontMatterExtension::class, 53 BenBjurstrom\Prezet\Extensions\MarkdownBladeExtension::class, 54 BenBjurstrom\Prezet\Extensions\MarkdownImageExtension::class, 55 ], 56 57 'config' => [ 58 'heading_permalink' => [ 59 'html_class' => 'prezet-heading', 60 'id_prefix' => 'content', 61 'apply_id_to_heading' => false, 62 'heading_class' => '', 63 'fragment_prefix' => 'content', 64 'insert' => 'before', 65 'min_heading_level' => 2, 66 'max_heading_level' => 3, 67 'title' => 'Permalink', 68 'symbol' => '#', 69 'aria_hidden' => false, 70 ], 71 'external_link' => [ 72 'internal_hosts' => 'www.example.com', // Don't forget to set this! 73 'open_in_new_window' => true, 74 'html_class' => 'external-link', 75 'nofollow' => 'external', 76 'noopener' => 'external', 77 'noreferrer' => 'external', 78 ], 79 ], 80 ], 81 82 /* 83 |-------------------------------------------------------------------------- 84 | Images 85 |-------------------------------------------------------------------------- 86 | 87 | Configure how image tags are handled when converting from markdown. 88 | 'widths' defines the various widths for responsive images, 89 | while 'sizes' indicates the sizes attribute. 90 | Set 'zoomable' to true to enable Alpine-driven zoom on click. 91 */ 92 93 'image' => [ 94 95 'widths' => [ 96 480, 640, 768, 960, 1536, 97 ], 98 99 'sizes' => '92vw, (max-width: 1024px) 92vw, 768px',100 101 'zoomable' => true,102 ],103 104 /*105 |--------------------------------------------------------------------------106 | Sitemap107 |--------------------------------------------------------------------------108 | The sitemap origin is used to generate absolute URLs in your sitemap.109 | An origin consists of a scheme/host/port combination, but no path.110 | (e.g., https://example.com:8000)111 |112 */113 114 'sitemap' => [115 'origin' => env('PREZET_SITEMAP_ORIGIN', env('APP_URL')),116 ],117 118 /*119 |--------------------------------------------------------------------------120 | Metadata121 |--------------------------------------------------------------------------122 |123 | Prezet uses these values for JSON-LD structured data. 'authors' defines124 | named authors you can reference in front matter, and 'publisher' is used125 | as the default publisher for all content.126 |127 */128 129 /*130 |--------------------------------------------------------------------------131 | Structured Data132 |--------------------------------------------------------------------------133 |134 | Prezet uses these values for JSON-LD structured data. 'authors' defines135 | named authors you can reference in front matter, and 'publisher' is used136 | as the default publisher for all content.137 |138 */139 140 // https://schema.org/author141 'authors' => [142 'prezet' => [143 '@type' => 'Person',144 'name' => 'Prezet Author',145 'url' => 'https://prezet.com',146 'image' => 'https://prezet.com/favicon.svg',147 ],148 ],149 150 // https://schema.org/publisher151 'publisher' => [152 '@type' => 'Organization',153 'name' => 'Prezet',154 'url' => 'https://prezet.com',155 'logo' => 'https://prezet.com/favicon.svg',156 'image' => 'https://prezet.com/ogimage.png',157 ],158];
#Filesystem Configuration
By default, Prezet uses the 'prezet'
disk for reading and storing markdown files. You can change this by updating the PREZET_FILESYSTEM_DISK
environment variable or directly editing the filesystem
array above.
#Slug Configuration
The 'slug'
array controls how document URLs are generated:
source
: Determines how the base slug is generated'filepath'
: Uses the markdown file's path (default)'title'
: Uses the document's title from front matter
keyed
: Whentrue
, appends the front matterkey
to the slug (e.g.,my-post-123
)
Note that a slug
defined in front matter will always take precedence over these generated slugs.
#CommonMark Configuration
Prezet uses league/commonmark for markdown parsing. In the 'commonmark'
array, you can:
- Define the extensions array to add or remove functionality (e.g.,
HeadingPermalinkExtension
,ExternalLinkExtension
, etc.). - Provide a
'config'
array with per-extension options, like theheading_permalink
orexternal_link
keys shown above.
#HeadingPermalinkExtension Options
For example, if you enable the HeadingPermalinkExtension
:
1'heading_permalink' => [ 2 'html_class' => 'mr-2 scroll-mt-12', 3 'id_prefix' => 'content', 4 'apply_id_to_heading' => false, 5 'heading_class' => '', 6 'fragment_prefix' => 'content', 7 'insert' => 'before', 8 'min_heading_level' => 2, 9 'max_heading_level' => 3,10 'title' => 'Permalink',11 'symbol' => '#',12 'aria_hidden' => true,13],
the extension will automatically insert permalink anchors for headings in your rendered HTML.
#Image Optimization
The 'image'
array controls how inline markdown images are transformed:
widths
: Defines the widths used insrcset
.sizes
: Specifies the sizes attribute for responsive images.zoomable
: Enables an Alpine-based zoom feature on click.
See Optimized Images for details on how Prezet automatically generates multiple responsive image URLs and updates your markdown output to reference them.
#Metadata (JSON-LD)
Prezet automatically includes JSON-LD metadata for each document, enhancing its visibility in search engines and social media. This is driven by two arrays:
authors
: An associative array mapping from anauthor
key in your front matter to a fully-defined schema.org object.publisher
: The fallback publisher metadata used when the document has no specific publisher or image.
For more on how this is injected into your templates, see the JSON-LD documentation.
#Additional Customizations
Prezet offers various customization options beyond the configuration file. Here are some additional resources for customizing different aspects of Prezet:
These articles will guide you through tailoring Prezet to your specific needs.