In this blog post, you’ll learn about how to design and develop Lightning Communities for search engine optimization (SEO). We’ll tell you how to accomplish this with product features and best practices in mind.

A key component of any successful public-facing website (or community) is the ability for customers to even know that your content exists. SEO has been around since the days of dial-up, but now more than ever Google, Bing, and other search engines are the default starting points for consumers taking a trip through the good ole’ Internet.

In Community Cloud, we understand just how important it is that your community is optimized to deliver the most SEO ‘juice’ to deliver value to your customers and your business. Our goal is to help everyone from Community Cloud beginners to gurus understand exactly how the product works behind-the-scenes today and how easy it is for anyone to quickly configure additional metadata tags, etc.

If you’re new to SEO and Lightning Communities, we recommend reviewing the SEO for Communities FAQ documentation to understand the basics.

Single-page apps & SEO

It’s important to know that Lightning Communities are single-page applications (SPA); the same framework that sites like Gmail and Facebook leverage. Unlike traditional websites which are made up of a network of individual pages, single-page apps load a single HTML “frame” and uses AJAX and HTML5 to dynamically update the content rendered out to the end user.

While search engines have made significant improvements on how they can index and crawl JavaScript-based sites they don’t always ‘love it.’ To help on this front, we generate a ‘static’ HTML view of every page in your community that is served up to search engines based on the user-agent string (ex: googlebot). This is where end-users will continue to see the JavaScript-based experience.

Understanding the auto-generated sitemap file

Do you have a Lightning Community? Have you enabled public access in the Community Builder, published your community and activated it in Community Management Console (CMC) or Workspaces? Congratulations, you now have an auto-generated sitemap file for your community (sitemap.xml) that adheres to the standard sitemap protocols. The easiest way to view the content of your sitemap.xml file is simply to add “sitemap.xml” after your community url (ex: If you are not finding the file then quickly double-check the status of your community.

Did I mention that we don’t create the sitemap.xml file for Sandbox orgs? We’ve heard your feedback loud and clear so we are reevaluating the criteria behind this decision. In the interim if you want to enable the sitemap.xml file in a Developer Edition Org you can create a support ticket with Salesforce requesting that the permission be enabled.

Generating the sitemap.xml file

Once your community is published and activated, an internal process is triggered to “index” your Lightning community to generate the proper sitemap.xml files. As search engines are essentially guest (unauthenticated) users coming to your community, this internal process leverages the Guest User Profile that is automatically generated when public access is granted in the Community Builder:

All standard community pages (ex: Home, Contact Support, Search, etc) that have not been marked as “Requires Login” in page properties will be included and captured in sitemap-view-[ ].xml. By default all Chatter-related pages (i.e. Topics, Discussions, etc) and public Groups will also be included in your sitemap under sitemap-topic-[ ].xml, sitemap-question-[ ].xml and sitemap-collaborationgroup-[ ].xml.

Object pages which are used to represent object data (List View, Record View, Related List View) play by a slightly different set rules given that you may only want to expose a subset of objects within a community – and only a subset of those objects to a guest user. For example, if I have given my Guest User Profile read access to several standard objects (Accounts, Cases, Contacts, etc), then corresponding sitemap entries for every record page in those objects will be generated.

It’s important to know that even though all of the records of our Products object will be included in the sitemap.xml file, the ability for a guest user access to the underlying data (record) through the community is still determined by Salesforce security (sharing rules, field-level security, permission sets, etc).

Note: If you have enabled multiple languages for your community we will automatically include all the relevant lang_local combinations for the community page URLs (ex: /s/home?language=en_US and /s/home?language=es_MX).

Why am I not seeing some pages in my sitemap?

Here is a quick checklist to run through if you’re not finding community pages in your sitemap.xml file:

  • You have published any updates (ex: adding new pages) to your community.
  • For standard pages make sure that the page access is not set to “Requires Login.”
  • For object pages make sure that the Guest User Profile of the community has at least “read” access for the corresponding object.
  • If you are using URL parameters in a standard page to deliver any dynamic data (ex: /s/product?productId=12345), this will not be crawled by the internal process that generates the sitemap.xml file. This is because we do not know what values are valid for the parameter(s) and what the underlying Salesforce object is. Instead you should leverage object pages in your community (ex: /s/product/12345) for all of the record pages to be crawled.

Setting yourself up for success

  • Always review what objects your Guest User Profile has access to before activating your community. Not only is this a best practice for controlling the scope of your sitemap.xml file, but it’s a best practice for keeping your community secure.
  • Make use of the “Change Base URL” feature available in page properties for object pages to create more SEO-friendly names (as the name for your custom objects might not have been designed with that in mind).
  • Review the accuracy of your sitemap.xml file before submitting it to Google, Bing, etc. Every search engine has their own rules around how frequently they will reindex sitemap submissions.
  • Consider making use of optional URL parameters to generate more SEO-friendly URLs in your community.

Page-level SEO optimization (New in Spring ‘18)

With the Spring ‘18 release we have expanded our support for more meta tags and added support for more granular and dynamic, page-level SEO customization. Let’s take a look.

  • Meta tags: On both standard and object pages a new “Edit Meta Tags” button is available which allows you to configure meta tags for individual community pages that will be rendered in addition to any “global” meta tags that you have configured in the Head Markup of your community.
  • Dynamic record detail page titles and descriptions: You now have more control and flexibility over the generation of your record detail page <title> and <meta name=”description”> values. Use expressions to dynamically display record-level values for any field on the object that the Guest User Profile has access to. Say goodbye to the days of being stuck with a single page title, or hacking your way through DOM injection with custom Lightning components.

Adding social media tags

You like sharing things, we like sharing things and so do your customers. With expanded support for additional meta tags and tag values it’s easier than ever to configure your social media tags from OpenGraph to Twitter through the Head Markup of your community.

And with page-level meta tag support you can choose to either augment, or override, any ‘global’ tags that you may have configured within your Head Markup.

Note that in the future we plan to support $Resource.resourceName in our meta tag editors, but for now you should leverage the following URL pattern for static resources within Community Builder: /sfsites/c/resource/{resource name}.

Additional tips & tricks

  • Supporting organic crawling: Submitting the sitemap.xml file for indexing is only part of the story. Always leverage the force:navigateToURL to generate properly formed <a href> links in your custom Lightning components to help with organic page crawling as well.
  • Robots.txt vs. <noindex>: Remember that the two are not the same and ultimately you may want a combination of both to control what pages are crawled and/or indexed by search engines. We recommend that you review this article by Google to help guide you. You can learn details on how to implement a custom robots.txt file for your community here and with page-level meta tag support you can also implement ‘noindex’ on the desired pages.
  • Third-party SEO analysis tools: As we are a single-page application (SPA) framework, if you plan to use any third-party SEO tools to scan your community make sure that they are configured properly to crawl JavaScript-based sites (ex:
  • Validating page indexing: Relying on Google’s “site: xxx” search pattern is a good way to check the general status of your community pages being indexed, but is not always 100% accurate.
  • Performance: Don’t forget the importance that site speed can play in SEO. Leverage our free Salesforce Community Page Optimizer plug-in (Chrome) from day one of your development.


About the authors

  • David Green (@d_l_green) is a product manager in the Community Cloud team that is passionate about enabling our developers and partners to deliver rich and immersive digital experiences.
  • Ken Hui is an engineering manager in the Community Cloud team who looks out over the underlying technology platform and features that power every Lightning community.
  • Dmitry Vinnick (@DmitryVinnik) is an engineer in the Community Cloud team that has been working on building a first-class product and SEO experience.
  • Henry Chen (@HenryChen_sfdc) is an engineer in the Community Cloud team that has been working on building a first-class product and SEO experience.

Get the latest Salesforce Developer blog posts and podcast episodes via Slack or RSS.

Add to Slack Subscribe to RSS