We use cookies to make your viewing experience better. By accepting you consent, you agree to our Cookie policy

Accept
Improve your Craft CMS skills

Understanding Tags In Craft CMS

10 min read
Understanding Tags In Craft CMS

Effectively using tags in Craft CMS unlocks content discoverability, flexibility, and insights. But poorly optimized tags create clutter and inconsistencies. This guide provides invaluable techniques to overhaul your tagging strategy. Learn how to build a streamlined taxonomy that enhances SEO, structure, and governance across entries, assets, and global sites. With these actionable best practices, you can transform scattered tags into a strategic information asset.

Tags in Craft CMS enable powerful content organization and discoverability. This guide covers creating clean tag taxonomies, utilizing advanced features like hierarchies and propagation, optimizing for SEO and voice search, managing tags across multi-site setups, leveraging APIs for headless Craft, translating tags across locales, and securing permissions. Proper tagging strategy enhances structure, governance and insights.

Creating and Managing Tags in Craft CMS

Setting up New Tag Groups

When creating a new Craft CMS website, one of the first steps is setting up tag groups to organise your content tagging. Tag groups allow you to separate tags into logical collections like 'News Topics', 'Product Categories' or 'Team Members'.

To add a new tag group, go to Settings > Tags and click the 'New tag group' button. Give your group a name like 'News Categories' and set the handle to something SEO-friendly like 'newsCategories'. The handle creates the URL segment for the tag group.

In the settings, you can select whether to make the group's tags restricted. Restricted tags can only be assigned to entries by admins, preventing other authors from using them improperly. For an open tag group like 'News Categories', leave it unrestricted.

You can also choose whether the tag group should be enabled for propagation. Propagated tags automatically get assigned to related entries. For something broad like 'News Categories', enable propagation.

Adding, Editing and Deleting Tags

Once your tag groups are created, it's easy to add, edit and remove tags within them. Go to the group and click the 'New tag' button to create a new tag. Give it a title like 'Local News' and a handle like 'localNews'.

The handle creates the URL segment, so make it web-friendly. You can add a description that gives authors usage guidance.

To later edit a tag, hover over it and click the gear icon. You can change the name, handle, or description here. If you need to delete an outdated tag, click the trash can icon.

When adding tags, focus on creating a comprehensive taxonomy relevant to your content. For news categories, tags like Politics, Business, Sports and Lifestyle work well. Avoid overly narrow tags that have few uses.

Managing Tag Organization

With lots of tags, organization becomes important. Craft lets you create tag hierarchies with parent and child tags for more structure. Go to a tag and set its parent tag in the settings to nest it.

You can also drag and drop tags to reorder them within a group. Keep your most-used tags on top for easy access when tagging entries. Tag organization helps authors use the correct tags consistently.

As your tag library grows, look for opportunities to merge duplicates. If two tags like 'Football' and 'Soccer' actually mean the same thing, merge them by turning one into an alias. This keeps usage consistent.

For widely used tags, enable propagation to automatically apply them to related entries, based on factors like entry type or channel. This saves authors time without sacrificing tagging accuracy.

With robust tag group creation and ongoing tag management, you can build a clean taxonomy that enhances your Craft CMS site's organization and search effectiveness.

Shape May 2022 HR 20 andy

Using Tags for Content Elements in Craft

Tagging Entries and Pages

One of the biggest uses for tags in Craft CMS is categorizing and organizing entries and pages. For example, you can tag blog posts and articles with relevant topics so they are easier to browse and search.

When creating a new entry or page in Craft, look for the 'Tags' field to assign tags. Simply start typing to select from existing tags, or create a new one on the fly. You can assign multiple tags to an entry or page as needed.

For a blog post on rising football ticket costs, relevant tags could be 'Football', 'Sports' and 'Business'. Tags make it easy for readers to find related content later.

Consider enabling propagation on frequently used tags like 'News' or 'Reviews'. This automatically applies these tags to entries in certain sections, saving authors time while improving consistency.

Take advantage of tag hierarchies too. Nest a 'Football' tag under 'Sports' and a 'Business' tag under 'News Topics' to create relationships between your tags. This enhances discoverability.

Organizing Assets with Tags

In addition to entries and pages, tags are handy for organizing assets like images, videos, PDFs and other files in Craft.

When uploading a new asset, enter relevant tags in the Tags field the same as for entries. For a product image, 'Electronics' and 'Phones' tags make sense. Tags enable logical grouping of assets.

You can create tag-specific asset volumes too. This allows only assets with certain tags to be uploaded to those volumes. For your team photos, make a 'Team Members' volume restricted to assets tagged 'Staff'.

When searching assets in Craft, you can filter by tag to quickly find related assets. Need a mountain photo? Filtering for the 'Landscape' tag makes it easy. Tags are invaluable for asset organization.

Tagging Products in Ecommerce

For ecommerce stores using Craft Commerce or other plugins, products benefit enormously from intelligent tagging.

Well-organized product tags allow shoppers to efficiently filter products on your site, improving the shopping experience. Tags like 'Electronics', 'Furniture' and 'Clothing' enable logical product grouping.

Look for tag overlap between products to identify related products shoppers may be interested in. 'Workplace', 'Ergonomic' and 'Office' are related tags between desk and chair products, for example.

Tag organization is key too. Use parent and child tag relationships like 'Furniture' as parent to 'Chairs' and 'Desks' to create a clear taxonomy.

Overall, meticulous product tagging results in increased sales. Shoppers can drill down to find exactly what they want, and discover more potential purchases along the way.

Advanced Tag Features in Craft CMS

Hierarchical Tag Structures

While simple flat tags work, hierarchical tags transform your content organization in Craft CMS. Parent-child tag relationships enable tree-like structures.

For example, create a 'Geography' parent tag then add child tags for 'Europe', 'Asia', 'Africa' etc. Under 'Europe', you could nest child tags for each country.

This builds logical connections between tags. Assigning a 'France' tag automatically associates the parent 'Europe' and top-level 'Geography' tags too.

Use hierarchies to simplify tag management. With hundreds of location tags, it is easier to edit them under region/country parents rather than a giant flat list.

When searching or filtering content by tag, users can leverage these relationships. Finding content tagged 'France' will also retrieve items tagged with its parent 'Europe'.

Merging Duplicate Tags

As your tag library grows, duplicate tags can emerge when authors create new tags willy-nilly. Consolidate these with Craft's merge tags feature.

For example, you may have 'Household' and 'Housewares' tags covering the same concept. Rather than choosing, merge them together.

Go to one tag and enter the handle of the other in the Merge Tags field. This designates that tag as the primary. Clicking Save Tag merges any content assigned those tags.

You can also make one tag an alias of another. The alias won't show up when tagging but will resolve to the primary tag. Useful for deprecated tags with existing relations.

Tag merging eliminates fragmentation, ensuring your content is consistently tagged. Regularly review tags for consolidation opportunities to prevent tag bloat.

Propagating Tags

Tag propagation automatically assigns certain tags to related content based on rules you define. This saves authors time while enhancing consistency.

For example, you may want to propagate a 'News' tag to any entry saved in the 'News' channel. Or propagate a 'Protected' tag to entries only visible to logged in members.

To set up propagation, go to a tag's settings and define the Entry Types, Sections or User Groups it should apply to. Click Save to enable the rules.

When authors create new entries meeting those conditions, the tag gets added automatically without them having to select it themselves every time.

Use propagation judiciously for broad, universally relevant tags. Avoid propagating overly specific niche tags that may not fit future content as well.

With Craft's robust tag features, you can build a clean, hierarchical taxonomy that enhances search, navigation and content organization on your site.

Tags for SEO and Metadata in Craft

Enabling Tag Archive Pages

One easy SEO win in Craft is enabling tag archive pages. This creates standalone pages that list entries associated with a specific tag.

To turn on, go to Settings > Sections. Choose a section like Blog or News that has tagged entries. Expand the Entry URL Format and select 'Tags' to archive entries by tag.

This will generate URLs like /news/business that display all news articles tagged 'Business'. It provides readers with a targeted landing page for relevant content.

Tweak the template to optimize these pages. Showpage title and meta descriptions should dynamically change based on the tag so each is unique. Improve discoverability by listing related tags too.

For better indexing, use Permalink Settings to remove .html extensions from tag archive URLs. Check they are loading successfully in Google Search Console.

Using Tags in URLs and Slugs

In addition to archives, directly integrate tags into your entry URLs/slugs for keyword targeting.

In your section's Entry URL Format, choose 'Entry slug' as the first segment then insert {postDate.year}/{tags} to dynamically add tags based on the entry's tags.

This appends the tags creating more URL-specific keywords, like /news/2023/business/finance-report. The tags help search engines quickly grasp the content's topic.

When adding tags to URLs, limit it to 1-2 important tags so they are legible. More can dilute the URL focus. Ensure your slugs remain concise as well.

Tagging for Voice Search

Voice search usage is soaring. Optimize tags to maximize discoverability and engagement for voice queries.

Observe how users naturally speak voice commands. Tag using conversational language that matches these natural voice requests.

For example, rather than a 'Recipes' tag, use 'Dinner ideas' or 'Weeknight meal inspiration' which mirrors how users may ask for recipes.

Use full natural phrases and questions as tags when feasible, instead of single generic keywords. Tags like 'How can I save money?' and 'What causes back pain?' directly answer voice queries.

Review voice search reports in Google Search Console to see the actual questions your content could rank for. Turn these into highly relevant corresponding tags.

With strategic tagging for SEO and voice search, Craft CMS content will surface prominently across the modern search landscape.

Managing Tags Across Multi-Site Setups

Shared Tag Groups

For publishers managing multiple Craft CMS sites, sharing tag groups between them provides consistency.

Rather than recreating the same tag groups separately everywhere, define certain groups as "shared" to make them available network-wide.

In the Craft admin, visit Settings > Tags. Choose your globally relevant groups like 'News Categories', 'Product Types' or 'Locations'. Check the Site Settings box and select the sites to share each with.

Now when editors visit these sites, those shared tag groups appear in addition to any local unshared groups. Authors can use the same shared tags on different sites.

To make edits, change the shared tag group on one site and it syncs across the others. New sites automatically get access to existing shared groups too.

Propagating Tags Across Sites

Along with shared access, propagate key tags across all sites to maintain unified content tagging.

For example, you likely want your 'Breaking News' tag applied consistently across sites. Set up propagation rules for it on one site.

Check the "Propagate to other sites" box when saving the tag. Choose which sites it should propagate to. Now when used on one site, it gets added everywhere.

Do this selectively for important universal tags to prevent irrelevant tags from spraying everywhere. Some tag uses are better left localized.

Regularly review propagation to ensure tags aren't being over-applied. Adjust the rules if some sites need more granular control.

Keeping Tags Synced

With shared tags flowing across sites, keep things in sync by limiting where edits occur.

Choose one primary site as the "source of truth" for each shared group. Clearly indicate in admin notes that this site owns tag management for the group across the network.

When tag changes are required, have admins from other sites request them from the owner rather than haphazardly making direct edits.

Monitor tag activity in the Craft audit log across sites. Watch for anomalies like deleted or merged tags on one site that don't sync correctly elsewhere. Quickly identify and fix discrepancies.

Use Craft's built-in tools like requiring admin changes or enabling version control on shared tag groups to prevent unauthorized local meddling too.

With robust tag sharing and monitoring, you can scale Craft CMS sites globally while providing a unified tagging experience.

Tag APIs and Headless Craft CMS

Fetching Tags via API

Craft's REST API enables headless delivery by letting you retrieve tag data through API calls.

To fetch all existing tags, make a GET request to /tags. This returns JSON for every tag across all groups. Filter by adding ?group=newsTags to get just that group's tags.

You can manipulate the response fields using parameters like ?fields=title,id to only return each tag's title and ID. _links adds URLs to related content with that tag.

For a single tag, use /tags/{id} passing the tag ID. Add ?status=enabled to only get enabled tags. Useful for syncing active tags to your headless implementation.

For integration with a JS framework, look into the Element API for optimized tag queries. The /elements endpoint has native support for tags as element types.

Modifying Tags via API

To modify tags in a headless environment, Craft offers Post API endpoints.

Create a new tag by POSTing to /tags with the tag title and group in the request body. The response returns the new tag ID.

To update a tag, make a PUT request to /tags/{id} with the updated properties in the request body. Want to delete a tag? Use DELETE at the same endpoint.

You can even reorder tags within a group using the /tags/order endpoint. The request body contains an array of tag IDs in the new order.

All write operations are available for headless systems to remotely manage tags without needing the Craft control panel.

JavaScript and Vue APIs

Alongside REST, Craft offers first-party JS and Vue APIs for frontend implementations.

Import craft.tags to interact with tags directly from your JavaScript code. Get all tags in a group with craft.tags.getAllTags('groupHandle')

Listen for tag events like tag creation using craft.tags.on('saveTag', callback) to trigger frontend updates.

For Vue, install the @craftjs/vue package. Now you can query tags through this.$craft.tags and hook into events via this.$craft.tags.on().

These friendly JS APIs eliminate the need for custom API wrappers. use the first-party methods to fetch, modify and listen for tag changes from your JavaScript code.

No matter your headless approach, Craft CMS offers multiple APIs to securely access and manage tags from anywhere.

Localization and Translating Tags

Tag Translation

For global, multi-language Craft CMS sites, translating tags creates localized experiences.

Craft lets you define tag translations so their names display in the proper locale language.

From a tag's settings, open Translation Key Management. Here you can add translations for each language your site supports.

For example, translate an 'Announcements' tag into Spanish, French and German versions. Authors will see the translated tag names in their locale.

Use localization tools to help with translation work rather than doing it manually. SYNC these translations back into Craft for a complete localized taxonomy.

For languages sharing characters, translate tag slugs/handles too so URLs localize properly. Keep SEO and localization intertwined.

Managing Tags Across Locales

When operating multi-language sites, strategically manage tags across locales.

Avoid creating duplicate tags in each language. Instead, translate a single tag to cover all languages for consistency.

For example, consolidate 'Announcements' and 'Ankündigungen' into one tag with translations rather than two separate tags.

Alternatively, have locale-specific tag groups for local concepts that don't translate globally. Merge these groups into a unified menu in the control panel to simplify management.

Plan shared and locale-specific tags upfront based on content needs. Audit existing tags to identify consolidation and translation opportunities.

Localize URLs for locale-specific tags by using translated slugs or locale prefixes like /en/business and /de/business.

With robust translation workflows and strategic localization, Craft's tags gracefully cross borders, languages and cultures. Your content will feel native for audiences everywhere.

Tag Security, Validation and Optimization

Securing Tag Permissions

Like all user-generated content, keep tags secure by limiting permissions.

By default, authors can create and manage tags freely. This lack of oversight leads to improper tagging and clutter.

Instead, create a dedicated "Tag Manager" role. Assign it permissions like 'Create tags', 'Edit tags' and 'Delete tags'. Standard authors get read-only access.

Now only specially permissioned users can add, modify or remove tags. They should proactively manage the taxonomy rather than reactively cleaning up author mistakes.

For further security, make certain sensitive tags like 'Customer Data' restricted. This requires admin approval before assigning them to content.

Regularly review tag permissions as your team and workflows evolve. Keep access aligned to tagging needs without being overly open.

Validating and Sanitizing Tags

Validate tags on the frontend to prevent malformed data from being introduced.

When users create tags, sanitize the values before saving them. Remove unwanted HTML, encode special characters, truncate lengths and prevent duplicate naming.

Customize the validation rules per tag group. Restrict news tags to ASCII characters while allowing wider Unicode support for global location tags.

On the backend, add Craft validation rules to enforce limits like maximum tag length or regex patterns tags must match. This provides server-side checking too.

Good validation eliminates inconsistencies and formatting issues that could break things like tag URLs down the road.

Optimizing Tag Performance

For large tag libraries, optimize performance with caching, eager loading and indexes.

Enable DB caching to avoid hitting the database for every tag query. Index commonly queried tag columns like handles and titles.

Eager load commonly associated relations like entry counts alongside tags. Optimize complex tag element queries at the template level to reduce load

Delete unused tags regularly to keep lookup tables lean. Archive old content with outdated niche tags rather than leaving it live.

With security, validation and performance best practices, you can smoothly scale your Craft CMS taxonomy as your content needs evolve.

Shape April 2022 HR 202
Andy Golpys
- Author

Andy has scaled multiple businesses and is a big believer in Craft CMS as a tool that benefits both Designer, Developer and Client. 

Share
Feedback
Show us some love
Email Us
We usually reply within 72 hours
Agency Directory
Submit your agency
Affiliate Partners
Let's chat