> Portal Navigation: > > - Append `.md` to any URL under `https://dev.wix.com/docs/` to get its markdown version. > - Pages are either content pages (article or reference text) or menu pages (a list of links to child pages). > - To get a menu page, truncate any URL to a parent path and append `.md` (e.g. `https://dev.wix.com/docs/sdk.md`, `https://dev.wix.com/docs/sdk/core-modules.md`). > - Top-level index of all portals: https://dev.wix.com/docs/llms.txt > - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt # Method name: getTagBySlug(slug: string, options: GetTagBySlugOptions) # Method package: wixBlogBackend # Method menu location: wixBlogBackend --> tags --> getTagBySlug # Method Link: https://dev.wix.com/docs/velo/apis/wix-blog-backend/tags/get-tag-by-slug.md # Method Description: Gets a tag by the specified slug. The `getTagBySlug()` function returns a Promise that resolves to a tag whose slug matches the specified slug. The `slug` is the end of a tag's URL that refers to a specific tag. For example, if a tag's URL is `https://example.com/blog/tag/{my-tag-slug}`, the slug is `my-tag-slug`. The slug is case-sensitive and derived from the tag's `label`. # Method Code Examples: *** Note: do not assume any prop names or enum values other than the ones in the example. ## Get a tag by its slug ```javascript import { tags } from 'wix-blog-backend'; /* Sample slug value: * 'my-tag' */ export async function getTagBySlugFunction(slug) { try { const result = await tags.getTagBySlug(slug); const label = result.tag.label; const postCount = result.tag.postCount; console.log('Retrieved result:', result); return result; } catch (error) { console.error(error); } } /* Promise resolves to: * { * "tag": { * "_createdDate": "2022-05-03T10:10:49.499Z", * "_id": "32970480-e53b-46e7-b52f-fba810a0b45d", * "_updatedDate": "2022-05-03T10:10:49.499Z", * "label": "my-tag", * "language": "en", * "postCount": 1, * "publishedPostCount": 1, * "slug": "my-tag", * "translationId": "" * } * } */ ``` ## Get a tag by its slug (export from backend code) ```javascript import { Permissions, webMethod } from 'wix-web-module'; import { tags } from 'wix-blog-backend'; /* Sample slug value: * 'my-tag' */ export const getTagBySlugFunction = webMethod(Permissions.Anyone, async (slug) => { try { const result = await tags.getTagBySlug(slug); const label = result.tag.label; const postCount = result.tag.postCount; console.log('Retrieved result:', result); return result; } catch (error) { console.error(error); } }); /* Promise resolves to: * { * "tag": { * "_createdDate": "2022-05-03T10:10:49.499Z", * "_id": "32970480-e53b-46e7-b52f-fba810a0b45d", * "_updatedDate": "2022-05-03T10:10:49.499Z", * "label": "my-tag", * "language": "en", * "postCount": 1, * "publishedPostCount": 1, * "slug": "my-tag", * "translationId": "" * } * } */ ``` ## Get a tag by its slug with additional fields ```javascript import { Permissions, webMethod } from 'wix-web-module'; import { tags } from 'wix-blog-backend'; /* Sample slug value: * 'my-tag' * Sample options value: * { * fieldsets: * [ * 'URL' * ] * } */ export const getTagBySlugFunction = webMethod(Permissions.Anyone, async (slug, options) => { try { const result = await tags.getTagBySlug(slug, options); const label = result.tag.label; const postCount = result.tag.postCount; const url = result.tag.url; console.log('Retrieved result:', result); return result; } catch (error) { console.error(error); } }); /* Promise resolves to: * { * "tag": { * "_createdDate": "2022-05-03T10:10:49.499Z", * "_id": "32970480-e53b-46e7-b52f-fba810a0b45d", * "_updatedDate": "2022-05-03T10:10:49.499Z", * "label": "my-tag", * "language": "en", * "postCount": 1, * "publishedPostCount": 1, * "slug": "my-tag", * "translationId": "", * "url": "http://https://tadasz7.wixsite.com/blog-velo-events/my-blog/tags/my-tag" * } * } */ ``` ---