Create a Custom Widget for a Static Page


I would like to create a custom widget for a Ghost Theme ( which I am working on.

The purpose of the widget is to display the first 12 words from a static page which I have already created within the site.

I’ve created the widget and it displays on my site, however, the text is hard coded - I would prefer that it pulls the words from the static page, as mentioned above.

This is my widget to date:

<div class="widget widget-tags u-shadow">
<h4 class="widget-title">About Me</h4>

    <img src="{{asset 'images/myPhoto.png'}}" width="100" height="100" alt="My Photo" longdesc="Photograph of Me" style="display: block; margin-left: auto; margin-right: auto" />
    Hi! My name is Joe Bloggs and I am a professional
    software developer.

All of my research on this area to date has shown me widgets associated with posts, but not static pages.

Any guidance or advice would be greatly appreciated.


When you say “static page” do you mean a page you created in Ghost Admin, or one you created in routes.yaml?

The latter cannot be pulled dynamically as they’re part of the theme, not the content.

The former can be pulled exactly the same way as posts, they’re just called pages:

1 Like

Hi Hannah. Cheers for the reply, really useful.

When I say “static page” I mean a page I’ve created in Ghost Admin. I’ve now used the link you provided on the Content API, and was able to create a custom integration to use the API for GET /content/pages/{id}/ . All good.

Now I’m trying to use the Content API JavaScript Client Ghost Docs to read the excerpt of the page.

I’ve got the following code, and I’m trying to assign the excerpt text to a div tag, but I can’t get it working.

<script src=""></script>

    const api = new GhostContentAPI({
        url: '',
        key: 'myKey',
        version: "v3"
    });{ id: 'pageID' });

    document.getElementById("aboutContent").innerHTML = api.pages.excerpt;// "Hello World";

I think it might be how I’m assigning the excerpt data into the innerHTML.

Any idea? :slight_smile:

Tony. returns a Promise… so your code needs to use then & catch as per the “Working Example” on the page you linked to:{ id: 'pageID' })
    .then((page) => {
    .catch((err) => {

1 Like

Thanks, Hannah. Really helpful, yet again :smiley: