How to use remote api(json data build with strapi) to build static website

I’m try to use strapi to build cms.
it can output json data form localhost link.
but I don’t know how to use that json data.
I tried use config.toml to config datasource like this

[[dataSources]]
source = "http://localhost:1337/posts"
contentPath = "posts"

  [dataSources.mapping]
  Title = "title"
  Date = "published_at"
  "Params.categories" = "category.title"

and json data is

[{
	"id": 1,
	"title": "title test",
	"content": "111111111111111111111",
	"published_at": "2021-08-30T09:23:41.000Z",
	"created_at": "2021-08-29T13:31:28.000Z",
	"updated_at": "2021-08-30T09:23:41.000Z",
	"category": {
		"id": 1,
		"title": "logs",
		"published_at": "2021-08-29T13:30:37.000Z",
		"created_at": "2021-08-29T13:30:33.000Z",
		"updated_at": "2021-08-29T13:30:37.000Z"
	}
}, {
	"id": 2,
	"title": "Strapi - Open source Node.js Headless CMS",
	"content": "111111111111111111111113333",
	"published_at": "2021-08-30T09:24:07.000Z",
	"created_at": "2021-08-30T09:24:06.000Z",
	"updated_at": "2021-08-30T09:24:13.000Z",
	"category": {}
}]

but it doesn’t work with default template.

You cannot create pages from external data.

If you are trying to add external data to existing pages, please post a link to the public repository for your project. Statements such as, “it doesn’t work with default template” are not helpful.

thanks. it means must have markdown files can create single page?

Yes, that is what it means.

What? Really?

I implemented alot of texts and images from strapi api but just wondering how to paginate though blog articles that are configures in Strapi. If this is not possible this would destroy my complete plan :smiley:

Did anyone manage to write blog posts in Strapi and use them in hugo?

there is a workaround if it can fit your setup.

1 Like

Great article @regis Learned so much from it, and from your other articles on The New Dynamic, thank you!

1 Like