Lesson
6
Generate social posts from your content
Speed up ideation of social media posts. And as a result, boost your SEO from sharing your content to a wider audience across different social platforms.
Log in to mark your progress for each Lesson and Task
This lesson uses features only available in paid plans. If you started a new project for this course, you can test these features during the free trial period. You can also start a new free project at any time.
Summarizing existing content and making it more useful in different forms is one of the best features of AI tooling. Sanity AI Assist makes it possible for authors to automatically generate new content, using existing fields along with prompts that they can save and share.
In this lesson you'll use Sanity AI Assist to generate text to post on social networks while sharing a link to the content.
Read more about Sanity AI Assist in the documentation
First you'll need new fields to write content to. Just like you made a new custom object schema type for SEO fields, create another for social networks.
In the example below we've chosen only LinkedIn and X (formerly known as Twitter) for now, feel free to include any of the countless others.
Create a new
social
object schema typesrc/sanity/schemaTypes/socialType.ts
import { defineField, defineType } from "sanity";
export const socialType = defineType({ name: "social", title: "Social", type: "object", fields: [ defineField({ name: "linkedIn", title: "LinkedIn", type: "text", rows: 3, }), defineField({ name: "x", description: "Formerly known as Twitter", type: "text", rows: 2, }), ],});
Don't forget to register this type to your Sanity Studio schema types
src/sanity/schemaTypes/index.ts
// ...all other importsimport { socialType } from "./socialType";
export const schema: { types: SchemaTypeDefinition[] } = { types: [ // ...all other types socialType, ],};
Update your
page
and post
schema types to include the social
field.src/sanity/schemaTypes/pageType.ts
export const pageType = defineType({ // ...all other settings fields: [ // ...all other fields defineField({ name: "social", type: "social", }), ],});
To automatically generate content for these fields, you'll now install and configure the Sanity AI assistant.
Run the following in your terminal
Terminal
npm install @sanity/assist
Update your Sanity Studio config file to include the
assist
pluginsanity.config.ts
// ...all other importsimport { assist } from "@sanity/assist";
export default defineConfig({ // ...all other config plugins: [ // ...all other plugins assist(), ],});
With this installed you can create a prompt to help Sanity AI Assist generate content from your existing fields.
Sanity AI Assist works at both field level and document level, however, for this example, you will be using the document level. Look at the top right of the Studio with any document open and you should see a sparkly new icon.
The first time you click this button you may be asked to Enable AI Assist
Click Enable AI Assist
You can see there are currently no instructions.
Click Add item to create your first instruction.
What we want AI Assist to do is to summarize the main body of the document
You're going to create a new prompt, use the example below for guidance.
Where you see the boxes like [Title]
, replace these with references to the fields in your document.
Make sure the Allowed fields is set to only write to the Social field object.
Create your new Instruction and run it
Take the content from [title] and [body] to generate text that will encourage people to click the link and find out more when this content is shared on social networks.
Writing prompts for AI is a bit of an art form! Take a look at the instructions cheat sheet in the documentation for inspiration.
By default, AI-generated copy can be generic. Consider adding some AI context documents (now visible in your Studio structure) to inform your preferred writing style and tone of voice. You can then add this context to your instruction, so that copy generated in future will be consistently informed.
In the following lesson, you'll create a dynamic sitemap that automatically updates when content changes. Helping search engines discover and index your content more effectively.
You have 7 uncompleted tasks in this lesson
0 of 7