> ## Documentation Index
> Fetch the complete documentation index at: https://docs.ghost.org/llms.txt
> Use this file to discover all available pages before exploring further.

# Ghost On The JAMstack

> How to use Ghost as a headless CMS with popular static site generators

export const EleventyLogo = ({width = 32, height = 32}) => <svg viewBox="0 0 1569.4 2186" xmlns="http://www.w3.org/2000/svg" width={width} height={height}>
    <rect x="-5%" width="110%" height="100%" fill="#222" />
    <g fill="#fff" stroke="#fff" strokeMiterlimit="10" strokeWidth="28">
      <path d="m562.2 1410.1c-9 0-13.5-12-13.5-36.1v-595.1c0-11.5-2.3-16.9-7-16.2-28.4 7.2-42.7 10.8-43.1 10.8-7.9.7-11.8-7.2-11.8-23.7v-51.7c0-14.3 4.3-22.4 12.9-24.2l142.2-36.6c1.1-.3 2.7-.5 4.8-.5 7.9 0 11.8 8.4 11.8 25.3v712c0 24.1-4.7 36.1-14 36.1zm368.3 1.1c-14.4 0-26.8-1-37.4-3s-21.6-6.5-33.1-13.5-20.9-16.6-28.3-28.8-13.4-29.3-18-51.2-7-47.9-7-78.1v-276.2c0-7.2-2-10.8-5.9-10.8h-33.4c-9 0-13.5-8.6-13.5-25.8v-29.1c0-17.6 4.5-26.4 13.5-26.4h33.4c3.9 0 5.9-4.8 5.9-14.5l9.7-209.5c1.1-19 5.7-28.5 14-28.5h53.9c9 0 13.5 9.5 13.5 28.5v209.5c0 9.7 2.1 14.5 6.5 14.5h68.7c9 0 13.5 8.8 13.5 26.4v29.1c0 17.2-4.5 25.8-13.5 25.8h-68.9c-2.5 0-4.2.6-5.1 1.9-.9 1.2-1.3 4.2-1.3 8.9v277.9c0 20.8 1.3 38.2 4 52s6.6 24 11.8 30.4 10.4 10.8 15.6 12.9c5.2 2.2 11.6 3.2 19.1 3.2h38.2c9.7 0 14.5 6.7 14.5 19.9v32.3c0 14.7-5.2 22.1-15.6 22.1zm206.7 64.6c8.2 0 15.4-6.7 21.5-20.2s9.2-32.6 9.2-57.4c0-5.8-3.6-25.7-10.8-59.8l-105.6-438.9c-.7-5-1.1-9-1.1-11.9 0-12.9 2.7-19.4 8.1-19.4h65.2c5 0 9.1 1.7 12.4 5.1s5.8 10.3 7.5 20.7l70 370.5c1.4 4.3 2.3 6.5 2.7 6.5 1.4 0 2.2-2 2.2-5.9l54.9-369.5c1.4-10.8 3.7-18 6.7-21.8s6.9-5.7 11.6-5.7h45.2c6.1 0 9.2 7 9.2 21 0 3.2-.4 7.4-1.1 12.4l-95.9 499.3c-7.5 41.3-15.8 72.9-24.8 94.8s-19 36.8-30.2 44.7c-11.1 7.9-25.8 12-44.2 12.4h-5.4c-29.1 0-48.8-7.7-59.2-23.2-2.9-3.2-4.3-11.5-4.3-24.8 0-26.6 4.3-39.9 12.9-39.9.7 0 7.2 1.8 19.4 5.4 12.4 3.8 20.3 5.6 23.9 5.6z"></path>
      <path d="m291.2 1411.1c-9 0-13.5-12-13.5-36.1v-595.1c0-11.5-2.3-16.9-7-16.2-28.4 7.2-42.7 10.8-43.1 10.8-7.9.7-11.8-7.2-11.8-23.7v-51.7c0-14.3 4.3-22.4 12.9-24.2l142.3-36.7c1.1-.3 2.7-.5 4.8-.5 7.9 0 11.8 8.4 11.8 25.3v712c0 24.1-4.7 36.1-14 36.1z"></path>
    </g>
  </svg>;

export const GridsomeLogo = ({width = 144, height = 28}) => <svg alt="Gridsome.org" fill="none" width={width} height={height} viewBox="0 0 1289 245" xmlns="http://www.w3.org/2000/svg"><path d="M221.494 101.381c11.78-.566 22.207 8.572 23.224 20.362 4.406 57.037-47.793 120.931-121.352 122.974C61.377 246.247.068 196.619.068 121.58c0-11.826 9.773-21.413 21.566-21.413s21.353 9.587 21.353 21.413c0 49.359 39.688 81.303 79.329 80.325 48.799-1.356 80.523-43.61 78.873-78.11-.566-11.812 8.526-21.847 20.305-22.414z" fill="url(#gridsome-logo_svg__paint0_linear)"></path><path d="M168.15 123.24c0-12.107 9.876-21.922 22.058-21.922h32.146c12.183 0 22.364 9.815 22.364 21.922 0 12.108-10.181 21.923-22.364 21.923h-32.146c-12.182 0-22.058-9.815-22.058-21.923zM100.7 123.272c0-12.125 9.813-21.954 21.904-21.954 12.092 0 21.905 9.829 21.905 21.954s-9.813 21.955-21.905 21.955c-12.091 0-21.904-9.83-21.904-21.955z" fill="#00A672"></path><path clip-rule="evenodd" d="M143.902 20.696c.49 11.816-8.666 21.792-20.449 22.283-50.865 2.118-81.918 42.097-80.407 80.057.47 11.816-8.51 21.778-20.293 22.25-11.784.472-22.147-9.065-22.617-20.881C-2.327 62.545 49.18 1.391 121.68.19c11.783-.49 21.732 8.69 22.221 20.506z" fill="#00A672" fill-rule="evenodd"></path><g clip-path="url(#gridsome-logo_svg__clip0)" fill="var(--body-color)"><path d="M408.102 137.495h41.203c-2.086 7.726-5.376 14.729-9.869 21.007-4.333 6.116-10.031 11.026-17.092 14.729-7.061 3.702-15.647 5.553-25.757 5.553-11.074 0-21.104-2.575-30.091-7.727-8.826-5.151-15.808-12.314-20.943-21.489-5.135-9.337-7.703-20.122-7.703-32.356 0-12.395 2.568-23.1 7.703-32.114 5.296-9.176 12.357-16.258 21.184-21.249 8.987-4.99 18.937-7.485 29.85-7.485 11.715 0 21.665 2.415 29.85 7.244 8.345 4.829 14.844 11.268 19.498 19.317l23.11-15.695c-7.382-11.751-17.252-20.927-29.609-27.527-12.197-6.6-26.48-9.9-42.849-9.9-12.678 0-24.474 2.174-35.387 6.52-10.752 4.185-20.14 10.141-28.165 17.868-7.863 7.727-14.042 16.983-18.535 27.768-4.333 10.624-6.5 22.375-6.5 35.253s2.167 24.709 6.5 35.494c4.333 10.786 10.431 20.122 18.295 28.01 8.024 7.888 17.412 14.004 28.164 18.351 10.753 4.185 22.468 6.278 35.146 6.278 13.481 0 25.437-2.415 35.868-7.244 10.432-4.99 19.178-11.751 26.239-20.283 7.061-8.531 12.357-18.27 15.888-29.216 3.531-11.107 5.135-22.859 4.814-35.253h-67.375l-3.437 24.146zM557.159 118.661l12.759-22.215c-2.568-2.897-5.617-4.99-9.148-6.278-3.53-1.287-7.302-1.931-11.314-1.931-4.654 0-9.228 1.449-13.721 4.346-4.494 2.737-8.345 6.6-11.555 11.59V90.651h-25.757v111.072h25.757v-62.538c0-8.049 1.444-14.488 4.333-19.317 2.889-4.829 7.543-7.244 13.962-7.244 3.21 0 5.858.564 7.944 1.69 2.086.966 4.333 2.415 6.74 4.347zM582.945 90.651v111.072h25.517V90.651h-25.517zm-3.611-40.74c0 4.507 1.605 8.29 4.815 11.348 3.209 3.059 7.061 4.588 11.555 4.588 4.654 0 8.585-1.53 11.795-4.588 3.21-3.058 4.815-6.841 4.815-11.349 0-4.507-1.605-8.29-4.815-11.348-3.21-3.059-7.141-4.588-11.795-4.588-4.494 0-8.346 1.53-11.555 4.588-3.21 3.058-4.815 6.841-4.815 11.349zM652.116 146.187c0-11.107 3.29-19.719 9.87-25.836 6.58-6.278 14.363-9.417 23.35-9.417 4.975 0 9.87 1.368 14.685 4.105 4.814 2.736 8.826 6.761 12.036 12.073 3.209 5.151 4.814 11.509 4.814 19.075 0 7.566-1.605 14.005-4.814 19.317-3.21 5.151-7.222 9.095-12.036 11.831-4.815 2.737-9.71 4.105-14.685 4.105-8.987 0-16.77-3.058-23.35-9.175-6.58-6.278-9.87-14.971-9.87-26.078zm-26.961 0c0 12.234 2.488 22.697 7.463 31.39 4.975 8.531 11.554 15.131 19.739 19.8 8.185 4.507 17.092 6.76 26.721 6.76 8.024 0 15.245-1.77 21.665-5.312 6.58-3.702 11.956-8.853 16.128-15.453v18.351h26.239V21.311h-26.239v87.691c-4.172-6.6-9.548-11.67-16.128-15.212-6.42-3.702-13.641-5.553-21.665-5.553-9.629 0-18.536 2.334-26.721 7.002-8.185 4.507-14.764 11.107-19.739 19.8-4.975 8.531-7.463 18.914-7.463 31.148zM772.658 161.641l-15.165 14.729c5.135 8.209 11.956 15.051 20.461 20.524 8.666 5.473 18.376 8.209 29.128 8.209 11.715 0 21.264-2.817 28.646-8.451 7.543-5.795 11.314-14.568 11.314-26.319 0-6.6-1.444-11.992-4.333-16.178-2.888-4.185-6.66-7.646-11.314-10.383-4.654-2.897-9.629-5.392-14.925-7.485a173.715 173.715 0 00-12.758-4.829c-4.173-1.449-7.623-3.139-10.351-5.071-2.729-1.931-4.093-4.426-4.093-7.485 0-3.38 1.284-5.795 3.852-7.244 2.728-1.609 6.339-2.414 10.833-2.414 4.493 0 9.147 1.288 13.962 3.863 4.975 2.576 9.308 5.876 12.999 9.9l14.443-14.971c-4.172-5.634-10.11-10.302-17.813-14.004-7.543-3.864-15.808-5.795-24.795-5.795-6.58 0-12.758 1.207-18.536 3.622-5.777 2.414-10.431 5.875-13.962 10.382-3.53 4.508-5.296 9.981-5.296 16.42 0 6.922 1.525 12.556 4.574 16.902 3.21 4.185 7.222 7.566 12.036 10.141 4.815 2.576 9.79 4.91 14.925 7.002 6.419 2.415 12.036 4.991 16.851 7.727 4.975 2.737 7.462 6.52 7.462 11.349 0 3.702-1.364 6.519-4.092 8.451-2.568 1.771-6.179 2.656-10.833 2.656-4.814 0-10.271-1.932-16.369-5.795-5.938-4.024-11.555-9.176-16.851-15.453zM884.632 146.187c0-10.463 3.13-18.914 9.389-25.353 6.419-6.439 14.283-9.659 23.591-9.659 9.468 0 17.332 3.22 23.591 9.659s9.388 14.89 9.388 25.353c0 10.302-3.129 18.753-9.388 25.353-6.259 6.439-14.123 9.659-23.591 9.659-9.308 0-17.172-3.22-23.591-9.659-6.259-6.6-9.389-15.051-9.389-25.353zm-26.72 0c0 11.429 2.568 21.49 7.703 30.183 5.296 8.692 12.438 15.533 21.425 20.524 9.147 4.829 19.338 7.243 30.572 7.243 11.394 0 21.585-2.414 30.572-7.243 8.987-4.991 16.048-11.832 21.183-20.524 5.296-8.693 7.944-18.754 7.944-30.183 0-11.429-2.648-21.49-7.944-30.182-5.135-8.693-12.196-15.454-21.183-20.283-8.987-4.99-19.178-7.485-30.572-7.485-11.234 0-21.425 2.495-30.572 7.485-8.987 4.829-16.129 11.59-21.425 20.283-5.135 8.692-7.703 18.753-7.703 30.182zM1150.99 131.217c0-14.005-2.89-24.629-8.67-31.873-5.77-7.405-14.68-11.107-26.72-11.107-7.38 0-14.12 1.77-20.22 5.312-6.1 3.38-10.99 8.129-14.68 14.246-4.98-13.039-15.57-19.558-31.78-19.558-7.22 0-13.48 1.69-18.77 5.07-5.14 3.38-9.23 7.888-12.28 13.522V90.651h-25.518v111.072h25.518v-67.609c0-7.405 1.84-13.361 5.54-17.868 3.85-4.668 9.3-7.002 16.36-7.002 6.75 0 11.48 2.173 14.21 6.519 2.73 4.185 4.09 10.302 4.09 18.351v67.609h26.24v-67.609c0-7.405 1.84-13.361 5.54-17.868 3.85-4.668 9.3-7.002 16.36-7.002 6.75 0 11.48 2.173 14.21 6.519 2.89 4.185 4.33 10.302 4.33 18.351v67.609h26.24v-70.506zM1193.64 152.224h88.35c.16-1.288.24-2.576.24-3.864.16-1.288.24-2.414.24-3.38 0-17.546-7.38-31.39-17.33-41.531-9.79-10.142-23.27-15.212-40.44-15.212-15.89 0-28.81 4.266-38.76 12.797-9.79 8.532-15.81 19.639-18.05 33.322a67.402 67.402 0 00-.73 5.795 73.142 73.142 0 00-.24 6.036c0 11.107 2.33 21.088 6.98 29.941 4.66 8.693 11.24 15.534 19.74 20.524 8.51 4.99 18.46 7.485 29.85 7.485 13.8 0 25.12-2.736 33.94-8.209 8.99-5.473 18.62-12.717 24.08-21.732l-25.04-9.175c-3.21 5.473-7.46 9.819-12.76 13.039-5.13 3.058-11.47 4.587-19.01 4.587-8.51 0-15.57-2.495-21.19-7.485-5.61-5.151-8.9-12.797-9.87-22.938zm.48-18.11c1.13-8.21 4.5-14.568 10.11-19.075 5.62-4.668 12.36-7.003 20.23-7.003 8.34 0 14.76 2.335 19.25 7.003 4.5 4.668 7.23 11.026 8.19 19.075h-57.78z"></path></g><defs><linearGradient gradientUnits="userSpaceOnUse" id="gridsome-logo_svg__paint0_linear" x1="122.523" x2="122.523" y1="100.167" y2="244.752"><stop stop-color="#00583E"></stop><stop offset="1" stop-color="#00835C"></stop></linearGradient><clipPath id="gridsome-logo_svg__clip0"><path d="M0 0h981v183H0z" fill="#fff" transform="translate(308 22)"></path></clipPath></defs></svg>;

export const NuxtLogo = ({width = 32, height = 32}) => <svg width={width} height={height} viewBox="0 0 512 512" fill="none" xmlns="http://www.w3.org/2000/svg">
    <path d="M281.44 397.667H438.32C443.326 397.667 448.118 395.908 452.453 393.427C456.789 390.946 461.258 387.831 463.76 383.533C466.262 379.236 468.002 374.36 468 369.399C467.998 364.437 466.266 359.563 463.76 355.268L357.76 172.947C355.258 168.65 352.201 165.534 347.867 163.053C343.532 160.573 337.325 158.813 332.32 158.813C327.315 158.813 322.521 160.573 318.187 163.053C313.852 165.534 310.795 168.65 308.293 172.947L281.44 219.587L227.733 129.13C225.229 124.834 222.176 120.307 217.84 117.827C213.504 115.346 208.713 115 203.707 115C198.701 115 193.909 115.346 189.573 117.827C185.238 120.307 180.771 124.834 178.267 129.13L46.8267 355.268C44.3208 359.563 44.0022 364.437 44 369.399C43.9978 374.36 44.3246 379.235 46.8267 383.533C49.3288 387.83 53.7979 390.946 58.1333 393.427C62.4688 395.908 67.2603 397.667 72.2667 397.667H171.2C210.401 397.667 238.934 380.082 258.827 346.787L306.88 263.4L332.32 219.587L410.053 352.44H306.88L281.44 397.667ZM169.787 352.44H100.533L203.707 174.36L256 263.4L221.361 323.784C208.151 345.387 193.089 352.44 169.787 352.44Z" fill="#00DC82" />
  </svg>;

export const HexoLogo = ({width = 32, height = 32}) => <svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width={width} height={height} viewBox="0 0 512 512" enable-background="new 0 0 512 512" xml:space="preserve">
    <path fill="#0E83CD" d="M256.4,25.8l-200,115.5L56,371.5l199.6,114.7l200-115.5l0.4-230.2L256.4,25.8z M349,354.6l-18.4,10.7
	l-18.6-11V275H200v79.6l-18.4,10.7l-18.6-11v-197l18.5-10.6l18.5,10.8V237h112v-79.6l18.5-10.6l18.5,10.8V354.6z" />
  </svg>;

export const NextLogo = ({width = 32, height = 32}) => <svg xmlns="http://www.w3.org/2000/svg" height={height} width={width} viewBox="0 0 16 16" strokeLinejoin="round" style={{
  color: 'currentColor'
}}>
    <g clipPath="url(#clip0_53_108)">
      <circle cx="8" cy="8" r="7.375" fill="black" stroke="var(--ds-gray-1000)" strokeWidth="1.25" strokeLinecap="round" strokeLinejoin="round" />
      <path d="M10.63 11V5" stroke="url(#paint0_linear_53_108vsxrmxu21)" strokeWidth="1.25" strokeMiterlimit="1.41421" />
      <path fillRule="evenodd" clipRule="evenodd" d="M5.995 5.00087V5H4.745V11H5.995V6.96798L12.3615 14.7076C12.712 14.4793 13.0434 14.2242 13.353 13.9453L5.99527 5.00065L5.995 5.00087Z" fill="url(#paint1_linear_53_108vsxrmxu21)" />
    </g>
    <defs>
      <linearGradient id="paint0_linear_53_108vsxrmxu21" x1="11.13" y1="5" x2="11.13" y2="11" gradientUnits="userSpaceOnUse">
        <stop stopColor="white" />
        <stop offset="0.609375" stopColor="white" stopOpacity="0.57" />
        <stop offset="0.796875" stopColor="white" stopOpacity="0" />
        <stop offset="1" stopColor="white" stopOpacity="0" />
      </linearGradient>
      <linearGradient id="paint1_linear_53_108vsxrmxu21" x1="9.9375" y1="9.0625" x2="13.5574" y2="13.3992" gradientUnits="userSpaceOnUse">
        <stop stopColor="white" />
        <stop offset="1" stopColor="white" stopOpacity="0" />
      </linearGradient>
      <clipPath id="clip0_53_108">
        <rect width="16" height="16" fill="red" />
      </clipPath>
    </defs>
  </svg>;

export const GatsbyLogo = ({width = 32, height = 32}) => {
  return <svg xmlns="http://www.w3.org/2000/svg" width={width} height={height} viewBox="0 0 28 28" focusable="false">
      <title>
        Gatsby
      </title>
      <circle cx="14" cy="14" r="14" fill="#639" />
      <path fill="#fff" d="M6.2 21.8C4.1 19.7 3 16.9 3 14.2L13.9 25c-2.8-.1-5.6-1.1-7.7-3.2zm10.2 2.9L3.3 11.6C4.4 6.7 8.8 3 14 3c3.7 0 6.9 1.8 8.9 4.5l-1.5 1.3C19.7 6.5 17 5 14 5c-3.9 0-7.2 2.5-8.5 6L17 22.5c2.9-1 5.1-3.5 5.8-6.5H18v-2h7c0 5.2-3.7 9.6-8.6 10.7z" />
    </svg>;
};

***

Ghost ships with a default front-end theme layer built with Handlebars, but based on its flexible [architecture](/architecture/) it can also be used as a headless CMS with third party front-end frameworks. We have setup guides for most of the most popular frameworks and how to use Ghost with them.

<CardGroup cols={3}>
  <Card title="Next.js" href="/jamstack/next/" icon={<NextLogo />} />

  <Card title="Gatsby" href="/jamstack/gatsby/" icon={<GatsbyLogo />} />

  <Card title="Hexo" href="/jamstack/hexo/" icon={<HexoLogo />} />

  <Card title="Nuxt" href="/jamstack/nuxt/" icon={<NuxtLogo />} />

  <Card title="VuePress" href="/jamstack/vuepress/" icon="https://mintlify.s3.us-west-1.amazonaws.com/ghost/images/vuepress-logo.png" />

  <Card title="Gridsome" href="/jamstack/gridsome/" icon={<GridsomeLogo />} />

  <Card title="Eleventy" href="/jamstack/eleventy/" icon={<EleventyLogo />} />

  <Card title="Custom Frontend" href="/jamstack/custom/" icon="sparkles" />
</CardGroup>

## Tips for using Ghost headless

Something to keep in mind is that Ghost’s default front-end is not just a theme layer, but also contains a large subset of functionality that is commonly required by most publishers, including:

* Tag archives, routes and templates
* Author archives, routes and templates
* Generated sitemap.xml for SEO
* Intelligent output and fallbacks for SEO meta data
* Automatic Open Graph structured data
* Automatic support for Twitter Cards
* Custom routes and automatic pagination
* Front-end code injection from admin

When using a statically generated front-end, all of this functionality must be re-implemented. Getting a list of posts from the API is usually the easy part, while taking care of the long tail of extra features is the bulk of the work needed to make this work well.

### Memberships

Ghost’s membership functionality is **not** compatible with headless setups. To use features like our Stripe integration for paid subscriptions, content gating, comments, analytics, offers, complimentary plans, trials, and more — Ghost must be used with its frontend layer.

### Working with images

The Ghost API returns content HTML including image tags with absolute URLs, pointing at the origin of the Ghost install. This is intentional, because Ghost itself is designed (primarily) to be source of truth for serving optimised assets, and may also be installed in a subdirectory.

When using a static front-end, you can either treat the Ghost install as a CDN origin for uploaded assets, or you can write additional logic in your front-end build to download embedded images locally, and rewrite the returned HTML to point to the local references instead.

### Disabling Ghost’s default front-end

When using a headless front-end with Ghost, you’ll want to disable Ghost’s default front-end to prevent duplicate content issues where search engines would see the same content on two different domains. The easiest way to do this is to enable ‘Private Site Mode’ under `Settings > General` - which will put a password on your Ghost install’s front-end, disable all SEO features, and serve a `noindex` meta tag.

You can also use dynamic redirects, locally or at a DNS level, to forward traffic automatically from the Ghost front-end to your new headless front-end - but this is a more fragile setup. If you use Ghost’s built-in newsletter functionality, unsubscribe links in emails will point to the Ghost origin - and these URLs will break if redirected. Preview URLs and other dynamically generated paths may also behave unexpectedly when blanket redirects are used.

Usually ‘Private Site Mode’ is the better option.

### Pagination for building static sites

Support for `?limit=all` when fetching data was removed in [Ghost 6.0](/changes#ghost-6-0), and all endpoints now have a max page size of 100.

This means any front-end frameworks that relied on `?limit=all` for building static pages, such as with `getStaticPaths()` in Next.js, should instead use pagination to fetch all of the needed data.

For example:

```js theme={"dark"}
// api.js
const api = new GhostContentAPI({
  url: 'https://demo.ghost.io',
  key: '22444f78447824223cefc48062',
  version: "v6.0"
});

// lib/posts.js
export async function getAllPostSlugs() {
  try {
    const allPostSlugs = [];
    let page = 1;

    while (page) {
      const posts = await api.posts.browse({
        limit: 100,
        page,
        fields: "slug", // Only the slug field is needed for getStaticPaths()
      });

      if (!posts?.length) break;

      allPostSlugs.push(...posts.map((post) => post.slug));
      // Use the meta pagination info to determine if there are more pages
      page = posts.meta.pagination.next || null;
    }

    return allPostSlugs;
  } catch (err) {
    console.error(err);
    return [];
  }
}

// pages/posts/[slug].js
export async function getStaticPaths() {
  const slugs = await getAllPostSlugs();

  // Get the paths we want to create based on slugs
  const paths = slugs.map((slug) => ({
    params: { slug: slug },
  }));

  return { paths, fallback: false };
}
```

In addition, consider building in small delays so as not to trigger any rate limits or fair usage policies of your hosts.
