Add a New Tag
Tags are essential for organizing content on your website. They help visitors find posts by topic and enhance site navigation. Follow the steps below to add a new tag in Try-O-Theme.
Step 1: Navigate to the Tags Directory
- Open your project directory.
- Go to the src/contents/tags/ folder. This folder contains all tag-related content.
Step 2: Create a New Tag Directory
- Create a new directory for your tag:
- Name the folder based on the tag name you want to add. For example:
mkdir src/contents/tags/my-new-tag
- Use lowercase letters and hyphens for consistency in folder naming.
- Name the folder based on the tag name you want to add. For example:
Step 3: Add an index.md File
- Inside the new directory (e.g., src/contents/tags/my-new-tag), create a file named index.md.
- This file stores the metadata for the tag.
- Add the following content to the index.md file:
Fields Explanation:--- type: tag title: My New Tag description: "A description for this tag." order: 1 ---
- type: Always set to tag.
- title: The display name of the tag.
- description: A short description of the tag’s purpose.
- order: Specifies the display order of tags, with lower numbers appearing first.
Step 4: Regenerate the Site
Once the tag is created, regenerate your 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 templates to incorporate the new tag.
Step 5: Verify the Tag
- Start the local development server:
toucan serve
- Open your browser and go to http://localhost:3000.
- Go to the Tags page to verify that the new tag is displayed.
Additional Notes
- Using Tags in Posts:
- To assign a tag to a post, include it in the tags field of the post’s index.md file. Example:
tags: - my-new-tag
- To assign a tag to a post, include it in the tags field of the post’s index.md file. Example:
- Styling Tags:
- To customize how tags are displayed, modify the relevant Mustache template in the src/themes/default/templates/ directory.
This guide ensures you can easily add and manage tags in Try-O-Theme.