Customization

Customizing Prezet Routes

When you run the prezet:install command the routes/prezet.php file is copied to your application. This file contains all the routes used by Prezet. The installer also appends a line to your routes/web.php file to include these routes.

#Default Routes

On a new install the contents of the routes/prezet.php file will look like this:

1Route::get('prezet/img/{path}', ImageController::class)
2 ->name('prezet.image')
3 ->where('path', '.*');
4 
5Route::get('/prezet/ogimage/{slug}', OgimageController::class)
6 ->name('prezet.ogimage')
7 ->where('slug', '.*');
8 
9Route::get('prezet', IndexController::class)
10 ->name('prezet.index');
11 
12Route::get('prezet/{slug}', ShowController::class)
13 ->name('prezet.show')
14 ->where('slug', '.*');

#Customizing the Path

One of the most common customizations is changing the base path for your blog. By default, Prezet uses 'prezet' as the base path to avoid conflict with any existing routes. Here's how you can change it:

  1. Open the routes/prezet.php file.
  2. Replace 'prezet' with your desired path (e.g., 'blog' or 'articles').

For example, to change the base path to 'blog':

1Route::get('blog', IndexController::class)
2 ->name('prezet.index');
3 
4Route::get('blog/{slug}', ShowController::class)
5 ->name('prezet.show')
6 ->where('slug', '.*');

#Using Root Path

If you want Prezet to handle your root path (e.g., for a documentation site), you can modify the routes like this:

1Route::get('/', IndexController::class)
2 ->name('prezet.index');
3 
4Route::get('{slug}', ShowController::class)
5 ->name('prezet.show')
6 ->where('slug', '.*');

#Customizing Other Routes

You can also customize the image and OG image routes if needed. Just make sure to update the paths consistently across all routes.

Note that Prezet uses named routes for some internal functionality so be sure to leave the route names unchanged.