Tokens
Welcome to the token system for your website! Tokens are a powerful tool that allows you to dynamically update and reuse content across your website, saving time and ensuring consistency. This guide will explain what tokens are, how to use them, and provide practical examples and benefits.
#What Are Tokens?
Tokens are placeholders for data that can be inserted anywhere on your website. Instead of writing the same information multiple times across pages, you can use a token. When the token’s value is updated, the change will reflect wherever the token is used.
Types of Tokens
- User-Generated Tokens (
[[tk.*]]
): These are custom tokens you create for specific needs, such as promotional messages or reusable text. - Site Tokens (
[[st.*]]
): Predefined tokens linked to your site’s information, such as contact details, business name, or hours.- Available Site Tokens
- name. Usage example:
[[st.name]]
- legalName: Usage example:
[[st.legalName]]
- url: Usage example
[[st.url]]
- contactInfo:
- email: Usage example
[[st.contactInfo.email]]
- phone: Usage example
[[st.contactInfo.phone]]
- location: Usage example
[[st.contactInfo.location]]
- hours: Usage example
[[st.contactInfo.hours]]
- email: Usage example
- name. Usage example:
- Available Site Tokens
How to Create Custom Tokens
Tokens and token groups as easily created your "Tokens" data file. You can create single tokens or token groups that can have singles or even more groups. Talk about tokenception.
Benefits of Using Tokens
- Time-Saving: Update content in one place and see it change everywhere.
- Consistency: Avoid mismatched or outdated information.
- Scalability: Ideal for frequently updated content like promotions or seasonal changes.
When to Use Tokens
- Use Tokens:
- For information that appears in multiple places (e.g., contact details).
- For content that changes regularly (e.g., promotions).
- Avoid Tokens:
- For static or rarely updated content (e.g., About Us page).
- When the complexity of managing tokens outweighs the benefit.
How to Use Tokens
Syntax
Tokens follow a specific format depending on their type:
- User-Generated Tokens:
[[tk.key]]
or[[tk.groupName.key]]
- Site Tokens:
[[st.key]]
or[[st.contactInfo.key]]
Examples of Token Usage in Text
- Using a Single Token: "For inquiries, email us at [[st.contactInfo.email]]."
- Using a Token Group: "Visit us at [[st.contactInfo.location]]. Call us at [[st.contactInfo.phone]]. We’re open [[st.contactInfo.hours]]."
Common Use Cases
1. Displaying Contact Information
Scenario: You want your contact details to appear consistently across your website.
Solution:
Use the st.contactInfo
tokens:
Example Text: "Feel free to reach out to us at [[st.contactInfo.email]] or call [[st.contactInfo.phone]]. You can visit our location at [[st.contactInfo.location]]. We’re open [[st.contactInfo.hours]]."
Outcome: If your email or phone number changes, update it once in the token configuration, and the change applies everywhere.
2. Promoting Special Offers
Scenario: You want to highlight a seasonal discount across your site.
Solution:
Create a user-generated token:
Example Token Definition:
[[tk.promo.discount]]
: "Get 15% off all services until December 31st!"
Example Text: "Don’t miss out on our latest deal: [[tk.promo.discount]]."
Outcome: Update the [[tk.promo.discount]]
token when the promotion changes, and all mentions update automatically.
3. Managing Team Information
Scenario: Showcase team members on a "Meet Our Team" page or within service-related content.
Solution:
Use a token group for team information.
Example Token Definition:
[[tk.team.leadTechnician.name]]
: "John Doe"[[tk.team.leadTechnician.title]]
: "Lead Technician"
Example Text: "Our team is led by [[tk.team.leadTechnician.name]], our highly skilled [[tk.team.leadTechnician.title]]."
Outcome: Easily update team details in one place as staff changes.
Advanced Usage
Token Groups
Token groups allow you to organize related tokens under a single category for better management.
Example:
- Group:
contactInfo
[[st.contactInfo.email]]
: "info@example.com"[[st.contactInfo.phone]]
: "123-456-7890"
Use these tokens anywhere on your site without duplicating information.
Slugified Keys
To ensure tokens are compatible, complex keys are "slugified," meaning special characters are replaced with hyphens (-
) and converted to lowercase. For example:
- User-defined key:
Sales/Contact Info
- Usable token:
[[tk.sales-contact-info]]
or[[tk.Sales/Contact Info]]
Both forms are valid, allowing flexibility in how tokens are referenced.
Tips for Managing Tokens
- Plan Your Tokens: Identify reusable content before creating tokens.
- Use Descriptive Keys: Choose clear, descriptive names for your tokens to avoid confusion.
- Test Before Updating: Preview your site after updating tokens to ensure they display correctly.
Summary
Tokens are a powerful way to manage content dynamically across your website. By using site tokens for common details like contact information and user-generated tokens for promotions or team details, you can ensure consistency and save time. While tokens are highly beneficial for frequently updated or reused content, they might be overkill for static information.
Start leveraging tokens today to simplify your website updates and create a seamless experience for your visitors!