[{"data":1,"prerenderedAt":462},["ShallowReactive",2],{"docs-\u002Fdocs\u002Fsite-kit\u002Fexternal-cms":3,"docs-navigation":313,"docs-surround-\u002Fdocs\u002Fsite-kit\u002Fexternal-cms":459},{"id":4,"title":5,"body":6,"description":305,"extension":306,"icon":307,"meta":308,"navigation":307,"path":309,"seo":310,"stem":311,"__hash__":312},"docs\u002Fdocs\u002F4.site-kit\u002F11.external-cms.md","External CMS",{"type":7,"value":8,"toc":300},"minimark",[9,13,28,74,84,89,184,187,191,197,201,204,241,244,247,280,296],[10,11,5],"h1",{"id":12},"external-cms",[14,15,16,17,22,23,27],"p",{},"A site whose content is in a headless CMS, such as Sanity, Directus, Payload or Strapi, keeps that CMS. Its build fetches the content, and Hostsmith hosts the built files. The site adds the ",[18,19,21],"a",{"href":20},"\u002Fdocs\u002Fsite-kit\u002Fexisting-astro-sites","core",", and declares the CMS in ",[24,25,26],"code",{},"hostsmith.json",":",[29,30,35],"pre",{"className":31,"code":32,"language":33,"meta":34,"style":34},"language-json shiki shiki-themes github-dark","\"content\": { \"source\": \"external\", \"provider\": \"sanity\" }\n","json","",[24,36,37],{"__ignoreMap":34},[38,39,42,46,50,54,57,60,63,66,68,71],"span",{"class":40,"line":41},"line",1,[38,43,45],{"class":44},"sU2Wk","\"content\"",[38,47,49],{"class":48},"s95oV",": { ",[38,51,53],{"class":52},"sDLfK","\"source\"",[38,55,56],{"class":48},": ",[38,58,59],{"class":44},"\"external\"",[38,61,62],{"class":48},", ",[38,64,65],{"class":52},"\"provider\"",[38,67,56],{"class":48},[38,69,70],{"class":44},"\"sanity\"",[38,72,73],{"class":48}," }\n",[14,75,76,79,80,83],{},[24,77,78],{},"provider"," names the CMS for the people who read the file. An external site's ",[24,81,82],{},"content"," holds only these two keys. Kit sites always keep their content in the repository.",[85,86,88],"h2",{"id":87},"what-the-site-gets","What the site gets",[90,91,92,107],"table",{},[93,94,95],"thead",{},[96,97,98,101,104],"tr",{},[99,100],"th",{},[99,102,103],{},"Content in the repository",[99,105,106],{},"Content in an external CMS",[108,109,110,122,144,160,173],"tbody",{},[96,111,112,116,119],{},[113,114,115],"td",{},"Editing",[113,117,118],{},"Decap CMS or Sveltia CMS, or a commit",[113,120,121],{},"the CMS's own editor",[96,123,124,130,133],{},[113,125,126,129],{},[24,127,128],{},".hostsmith\u002Fschema.json"," and the Decap config",[113,131,132],{},"yes",[113,134,135,136,139,140,143],{},"no: ",[24,137,138],{},"npx site-kit schema"," and ",[24,141,142],{},"npx site-kit decap-config"," write nothing and say why",[96,145,146,151,157],{},[113,147,148],{},[24,149,150],{},"check-fields",[113,152,153,154],{},"a gate with ",[24,155,156],{},"--min",[113,158,159],{},"a report only: the CMS's text has nothing in the repository to bind to",[96,161,162,169,171],{},[113,163,164,165,168],{},"Deploys, previews, ",[24,166,167],{},"check-urls",", updates, hosting",[113,170,132],{},[113,172,132],{},[96,174,175,178,181],{},[113,176,177],{},"A content change reaches the site",[113,179,180],{},"with a commit",[113,182,183],{},"when the CMS starts the deploy workflow",[14,185,186],{},"The site still builds to static files, so it shows published content only: draft previews and visual editing need a server, and aren't supported. Keeping the site up covers its code and the core: dependency and core updates, the checks and hosting. The CMS's account, schema and content stay with the CMS.",[85,188,190],{"id":189},"keep-the-token-secret","Keep the token secret",[14,192,193,194,196],{},"The build reads the CMS with its read token. Keep the token in the deploy workflow's GitHub environment secrets, never in ",[24,195,26],{}," or the repository.",[85,198,200],{"id":199},"rebuild-on-publish","Rebuild on publish",[14,202,203],{},"The deploy workflow also runs on demand, so the CMS can start a deploy when content is published. The CMS calls GitHub's API:",[29,205,209],{"className":206,"code":207,"language":208,"meta":34,"style":34},"language-http shiki shiki-themes github-dark","POST https:\u002F\u002Fapi.github.com\u002Frepos\u002FOWNER\u002FREPOSITORY\u002Factions\u002Fworkflows\u002Fhostsmith.yml\u002Fdispatches\nAuthorization: Bearer \u003Ctoken>\nAccept: application\u002Fvnd.github+json\n\n{\"ref\": \"main\", \"inputs\": {\"target\": \"production\"}}\n","http",[24,210,211,216,222,228,235],{"__ignoreMap":34},[38,212,213],{"class":40,"line":41},[38,214,215],{},"POST https:\u002F\u002Fapi.github.com\u002Frepos\u002FOWNER\u002FREPOSITORY\u002Factions\u002Fworkflows\u002Fhostsmith.yml\u002Fdispatches\n",[38,217,219],{"class":40,"line":218},2,[38,220,221],{},"Authorization: Bearer \u003Ctoken>\n",[38,223,225],{"class":40,"line":224},3,[38,226,227],{},"Accept: application\u002Fvnd.github+json\n",[38,229,231],{"class":40,"line":230},4,[38,232,234],{"emptyLinePlaceholder":233},true,"\n",[38,236,238],{"class":40,"line":237},5,[38,239,240],{},"{\"ref\": \"main\", \"inputs\": {\"target\": \"production\"}}\n",[14,242,243],{},"The token is a fine-grained GitHub personal access token for that repository only, with the \"Actions\" repository permission at \"Read and write\". Keep it in the CMS's secret settings.",[14,245,246],{},"How each CMS sends the call:",[248,249,250,258,264,274],"ul",{},[251,252,253,257],"li",{},[254,255,256],"strong",{},"Sanity:"," a GROQ-powered webhook, which fires when a change is published, not for drafts.",[251,259,260,263],{},[254,261,262],{},"Directus:"," a Flow with an event hook trigger and a webhook operation.",[251,265,266,269,270,273],{},[254,267,268],{},"Payload:"," an ",[24,271,272],{},"afterChange"," hook on each collection the site shows, since Payload has no webhook settings.",[251,275,276,279],{},[254,277,278],{},"Strapi:"," a Document Service middleware, since Strapi's own webhooks send a fixed body that GitHub's API rejects.",[14,281,282,283,289,290,295],{},"The README has ",[18,284,288],{"href":285,"rel":286},"https:\u002F\u002Fgithub.com\u002Fhostsmith\u002Fsite-kit-astro\u002Fblob\u002Fmain\u002FREADME.md#rebuild-on-publish",[287],"nofollow","each setup in full",", with the code for Payload and Strapi, and the rest of ",[18,291,294],{"href":292,"rel":293},"https:\u002F\u002Fgithub.com\u002Fhostsmith\u002Fsite-kit-astro\u002Fblob\u002Fmain\u002FREADME.md#content-in-an-external-cms",[287],"content in an external CMS",".",[297,298,299],"style",{},"html pre.shiki code .sU2Wk, html code.shiki .sU2Wk{--shiki-default:#9ECBFF}html pre.shiki code .s95oV, html code.shiki .s95oV{--shiki-default:#E1E4E8}html pre.shiki code .sDLfK, html code.shiki .sDLfK{--shiki-default:#79B8FF}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}",{"title":34,"searchDepth":218,"depth":218,"links":301},[302,303,304],{"id":87,"depth":218,"text":88},{"id":189,"depth":218,"text":190},{"id":199,"depth":218,"text":200},"Host an Astro site whose content is in a headless CMS such as Sanity, Directus, Payload or Strapi, and rebuild it when the CMS publishes.","md",null,{},"\u002Fdocs\u002Fsite-kit\u002Fexternal-cms",{"title":5,"description":305},"docs\u002F4.site-kit\u002F11.external-cms","HYdvHyJIC7xBp4Pi2ovaCt8LbxD7NoJE8T0of1vITrU",[314],{"title":315,"path":316,"stem":317,"children":318,"page":458},"Docs","\u002Fdocs","docs",[319,346,358,393,440],{"title":320,"path":321,"stem":322,"children":323,"page":-1,"icon":325},"Getting Started","\u002Fdocs\u002Fgetting-started","docs\u002F1.getting-started\u002Findex",[324,326,330,334,338,342],{"title":320,"path":321,"stem":322,"icon":325},"solar:rocket-bold",{"title":327,"path":328,"stem":329},"Introduction","\u002Fdocs\u002Fgetting-started\u002Fintroduction","docs\u002F1.getting-started\u002F1.introduction",{"title":331,"path":332,"stem":333},"Quick Start","\u002Fdocs\u002Fgetting-started\u002Fquick-start","docs\u002F1.getting-started\u002F2.quick-start",{"title":335,"path":336,"stem":337},"Sites","\u002Fdocs\u002Fgetting-started\u002Fsites","docs\u002F1.getting-started\u002F3.sites",{"title":339,"path":340,"stem":341},"Custom Domains","\u002Fdocs\u002Fgetting-started\u002Fcustom-domains","docs\u002F1.getting-started\u002F4.custom-domains",{"title":343,"path":344,"stem":345},"Support","\u002Fdocs\u002Fgetting-started\u002Fsupport","docs\u002F1.getting-started\u002F5.support",{"title":347,"path":348,"stem":349,"children":350,"page":-1,"icon":352},"Integrations","\u002Fdocs\u002Fintegrations","docs\u002F2.integrations\u002Findex",[351,353],{"title":347,"path":348,"stem":349,"icon":352},"ph:usb-bold",{"title":354,"path":355,"stem":356,"icon":357},"n8n","\u002Fdocs\u002Fintegrations\u002Fn8n","docs\u002F2.integrations\u002F1.n8n","simple-icons:n8n",{"title":359,"path":360,"stem":361,"children":362,"page":-1,"icon":364},"MCP","\u002Fdocs\u002Fmcp","docs\u002F3.mcp\u002Findex",[363,365,369,373,377,381,385,389],{"title":359,"path":360,"stem":361,"icon":364},"solar:plug-circle-bold",{"title":366,"path":367,"stem":368},"Quick start","\u002Fdocs\u002Fmcp\u002Fquick-start","docs\u002F3.mcp\u002F1.quick-start",{"title":370,"path":371,"stem":372},"Clients","\u002Fdocs\u002Fmcp\u002Fclients","docs\u002F3.mcp\u002F2.clients",{"title":374,"path":375,"stem":376},"Authentication","\u002Fdocs\u002Fmcp\u002Fauthentication","docs\u002F3.mcp\u002F3.authentication",{"title":378,"path":379,"stem":380},"Tools","\u002Fdocs\u002Fmcp\u002Ftools","docs\u002F3.mcp\u002F4.tools",{"title":382,"path":383,"stem":384},"Recipes","\u002Fdocs\u002Fmcp\u002Frecipes","docs\u002F3.mcp\u002F5.recipes",{"title":386,"path":387,"stem":388},"Limits and errors","\u002Fdocs\u002Fmcp\u002Flimits-and-errors","docs\u002F3.mcp\u002F6.limits-and-errors",{"title":390,"path":391,"stem":392},"FAQ","\u002Fdocs\u002Fmcp\u002Ffaq","docs\u002F3.mcp\u002F7.faq",{"title":394,"path":395,"stem":396,"children":397,"page":-1,"icon":399},"Site kit","\u002Fdocs\u002Fsite-kit","docs\u002F4.site-kit\u002Findex",[398,400,404,408,412,416,420,424,428,432,436,439],{"title":394,"path":395,"stem":396,"icon":399},"solar:layers-bold",{"title":401,"path":402,"stem":403},"Overview","\u002Fdocs\u002Fsite-kit\u002Foverview","docs\u002F4.site-kit\u002F01.overview",{"title":405,"path":406,"stem":407},"Start a site","\u002Fdocs\u002Fsite-kit\u002Fstart-a-site","docs\u002F4.site-kit\u002F02.start-a-site",{"title":409,"path":410,"stem":411},"Content","\u002Fdocs\u002Fsite-kit\u002Fcontent","docs\u002F4.site-kit\u002F03.content",{"title":413,"path":414,"stem":415},"Design","\u002Fdocs\u002Fsite-kit\u002Fdesign","docs\u002F4.site-kit\u002F04.design",{"title":417,"path":418,"stem":419},"Languages","\u002Fdocs\u002Fsite-kit\u002Flanguages","docs\u002F4.site-kit\u002F05.languages",{"title":421,"path":422,"stem":423},"Deploy with Hostsmith","\u002Fdocs\u002Fsite-kit\u002Fdeploy","docs\u002F4.site-kit\u002F06.deploy",{"title":425,"path":426,"stem":427},"Keep old URLs","\u002Fdocs\u002Fsite-kit\u002Fold-urls","docs\u002F4.site-kit\u002F07.old-urls",{"title":429,"path":430,"stem":431},"Work with an AI agent","\u002Fdocs\u002Fsite-kit\u002Fai-agents","docs\u002F4.site-kit\u002F08.ai-agents",{"title":433,"path":434,"stem":435},"Kit updates","\u002Fdocs\u002Fsite-kit\u002Fupdates","docs\u002F4.site-kit\u002F09.updates",{"title":437,"path":20,"stem":438},"Existing Astro sites","docs\u002F4.site-kit\u002F10.existing-astro-sites",{"title":5,"path":309,"stem":311},{"title":441,"path":442,"stem":443,"children":444,"page":-1,"icon":446},"Developers","\u002Fdocs\u002Fdevelopers","docs\u002F5.developers\u002Findex",[445,447,450,454],{"title":441,"path":442,"stem":443,"icon":446},"solar:code-bold",{"title":374,"path":448,"stem":449},"\u002Fdocs\u002Fdevelopers\u002Fauthentication","docs\u002F5.developers\u002F1.authentication",{"title":451,"path":452,"stem":453},"API Explorer","\u002Fdocs\u002Fdevelopers\u002Fapi-explorer","docs\u002F5.developers\u002F2.api-explorer",{"title":455,"path":456,"stem":457},"Node.js SDK","\u002Fdocs\u002Fdevelopers\u002Fsdk","docs\u002F5.developers\u002F3.sdk",false,[460,461],{"title":437,"path":20,"stem":438,"children":-1},{"title":441,"path":442,"stem":443,"icon":446,"children":-1},1792842402128]