How do I create a custom page in Drupal?

Create a custom module with a routing YAML file that declares a route pointing to a controller class. The controller method returns a render array describing the page’s content.

For example, your route might map /mypage to a method called content on MyPageController. The method returns an array with markup and metadata. Drupal renders it using your theme’s page template.

For simpler needs, you can create a basic page as a node using the core Basic Page content type. This gives editors the ability to manage the content through the admin interface without any custom code. Use custom routes when you need dynamic behaviour, custom logic, or programmatic control. Use content types when you just need a page with editable content. Both approaches are perfectly valid and commonly used side by side.

Facebook
Twitter
LinkedIn
Pinterest