How do I use SFDX tool to publish a community page on a scratch org?

Community migration/deployment from sandbox to sandbox is a mix of automated and manual steps, be it either using Change Sets, Metadata API and I would assume the same to be using CLI. Referring to the Salesforce CLI Command Reference, there doesn't seem to be a way to Publish the community using any command.

If you refer to other links around Community deployment using say Change Sets or Metadata API, you will find that you will still need to perform quite a few manual steps, including Publishing the community once you have deployed your components. You can find some information around this topic on the below links:

  • Deploy Lightning Communities
  • Deploy Your Community with Change Sets
  • Deploy Your Community with the Metadata API
  • Considerations for Deploying Communities with Change Sets

Update & Working Solution 1-28-2021:

  • The Salesforce CLI now has "Community" command.

  • Some run asynchronously, but they work.


  • There is a Create and a Publish command you can use.

  • In our org, we use python to automate the scratch org creation.

  • It goes something like: Create community, wait 2 minutes, force:push -F (force), Publish, Create users and apply permission set. Then login as a community user.

    sfdx force:community:create --name "My Customer Community" --templatename "Customer Service" --urlpathprefix customers --description "My customer community" sfdx force:community:publish --name "My Customer Community"