Create a Custom Page in Navigation
Adding a custom page is a great way to enhance your siteâs functionality by including pages like âContact Us,â âFAQ,â or other static content. Follow the steps below to create a custom page and add it to the navigation menu in T-Doc Theme.
Step 1: Edit the Navigation Menu
- Open the src/contents/index.yaml file in your project directory.
- This file
navigation
section manages the navigation menu displayed on your site.
- This file
- Add a new entry under the
navigation
section for your custom page. Example:
navigation:
- label: 'Docs'
url: '/docs/'
- label: 'About'
url: '/about/'
- label: 'Contact'
url: '/contact/'
- label: FAQ
url: '/faq/'
Fields Explanation:
- label: The text displayed in the navigation menu.
- url: The relative URL of the custom page.
Step 2: Create the Custom Page Directory
- Navigate to the src/contents/ folder.
- Create a new directory for your custom page. For example:
mkdir src/contents/faq
Step 3: Add an index.md
File
- Inside the new directory (e.g.,
src/contents/faq
), create a file namedindex.md
.- This file contains the metadata and content for the custom page.
- Add the following content to the
index.md
file:
Fields Explanation:--- title: "FAQ" description: "Frequently asked questions" template: pages.default_page ---
- title: The title of the custom page.
- description: A short description or summary of the pageâs content.
- template: The Mustache template used to render the page.
Step 4: Add Content to the Page
Below the metadata in index.md
, write the content of your custom page using Markdown. Example:
## FAQ
### How do I reset my password?
If you forgot your password, you can reset it by clicking the "Forgot Password" link on the login page.
### How can I contact support?
You can reach our support team at [support@example.com](mailto:support@example.com).
Step 5: Create a New Template (Optional)
- If the default template
pages.default_page
does not fit your needs, create a custom Mustache template:- Navigate to src/themes/default/templates/pages/.
- Create a new Mustache file, e.g.,
faq.mustache
.
- Update the
template
field in the custom pageâs metadata to use your new template:template: pages.faq
Step 6: Regenerate the Site
Once the custom page is created, regenerate the site to apply the changes:
- Open your terminal and navigate to your project directory.
- Run the following command:
toucan generate
- This updates the siteâs content and refreshes the navigation menu.
Step 7: Verify the Custom Page
- Start the local development server:
toucan serve
- Open your browser and go to http://localhost:3000/faq/.
- Ensure that the custom page is displayed correctly and can be accessed from the navigation menu.
Additional Notes
- Updating Content:
- You can edit the
index.md
file at any time to update the content of the custom page.
- You can edit the
- Styling:
- Update the relevant Mustache templates and CSS files in the themes/default/ directory to customize the pageâs look.
This guide will help you create and manage custom pages easily in T-Doc Theme.