Webflow sync, pageviews & more.
NEW

How can I dynamically update the meta title and description on a Webflow site using JavaScript? I want to display the updated information from a collection list on the page, but I am unsure if this will affect SEO.

TL;DR
  • Use JavaScript to update meta title and description dynamically by pulling values from hidden elements, but this won't improve SEO.
  • For SEO, configure meta tags in Webflow’s CMS Collection Template Page settings using dynamic fields like {{Name}} and {{Summary}}.

You can dynamically change the meta title and description on a Webflow site using JavaScript, but doing so comes with important SEO limitations.

1. Why JavaScript for Meta Tags Is Limited for SEO

  • Search engines like Google rely on server-rendered meta tags for indexing. If you modify meta tags after page load using JavaScript, there's no guarantee Google will see or process the changes.
  • This approach is useful mainly for client-side experiences, such as dynamically personalizing content after the site is rendered—not for SEO-critical content.

2. Dynamically Setting Meta Title and Description with JavaScript

  • You can update the document’s title and meta tag content like this in a script:

  • Title: document.title = 'New Title from CMS';

  • Description: document.querySelector('meta[name="description"]').setAttribute('content', 'New description from CMS');

  • To pull values from a Webflow Collection List item, place the values in hidden elements or data attributes, and then retrieve them using JavaScript. For example:

  • Add a hidden div with an attribute like data-title and data-description.

  • In JavaScript, fetch these values and update the title and meta:

    • const title = document.querySelector('[data-title]').getAttribute('data-title');
    • const desc = document.querySelector('[data-description]').getAttribute('data-description');
    • Then apply those values using the methods above.

3. SEO Implications and Best Practices

  • Modifying meta tags via JavaScript does not help with SEO, because:

  • Search engine bots may not run or wait for JavaScript execution.

  • The modified meta content won't appear in page source or server-rendered responses.

  • For SEO purposes:

  • Use Webflow’s CMS ‘SEO Settings’ fields in Collection Templates to set per-page meta titles and descriptions.

  • Go to the Collection Template Page, then click the Page Settings (gear icon), and populate the Title Tag and Meta Description fields using fields from your collection (e.g., {{Name}}, {{Summary}}).

4. When JavaScript Updates Are Appropriate

  • This approach is okay for:
  • Updating page metadata for social sharing previews using client-side apps.
  • Custom dynamic filtering pages that don't have unique URLs but need client personalization.
  • Avoid relying on it for SEO-critical pages like blogs, services, or product detail pages.

Summary

You can change the meta title and description using JavaScript for client-side personalization, but it won’t benefit SEO. For search engine optimization, set tags directly in Webflow’s CMS SEO settings on Collection Template pages.

Rate this answer

Other Webflow Questions