seo
seo copied to clipboard
Feed Me import support / format
Description
I've noticed that our SEO custom fields show up in Feed Me as a mapping option for an import. We're moving over a large amount of entries from an earlier site, so it would be great if we could migrate their custom SEO data.
I don't see anything in the docs about it, so is this supported? And if so, how does the data need to be formatted in the source?
utr
@idawgik not sure if you were able to get it figured out, but I think I found the solution if you still need it. Now, in my setup I only needed keywords, title, descriptions. I have not tested Opengraph images or any of the robots, but imagine it would work the same way.
Code to generate my JSON note the last line where it gets converted back into a json encoded string
Please not that I am migrating from WordPress so I am writing custom PHP to migrate my SEO fields over, so this code might look different for you. The important part is how keywords and the storing of your SEO are formatted.
Keywords need to be stored in their own objects with keyword
being the key for the keyword.
And when you are formatting your data to be imported making it a single json string is how the SEO plugin looks to be importing.
I hope this all makes sense.
if($out->SEO){
if($out->SEO->keyword){
$keywords = explode(', ', $out->SEO->keyword);
foreach($keywords as $keyword){
$migrate['entry'][$m]['seo']['keywords'][] = array(
'keyword' => $keyword
);
}
}
if($out->SEO->title){
$migrate['entry'][$m]['seo']['titleRaw']["1"] = $out->SEO->title;
}
if($out->SEO->meta_description){
$migrate['entry'][$m]['seo']['descriptionRaw'] = $out->SEO->meta_description;
}
if($out->SEO->fb_title){
$migrate['entry'][$m]['seo']['social']['twitter']['title'] = $out->SEO->fb_title;
$migrate['entry'][$m]['seo']['social']['facebook']['title'] = $out->SEO->fb_title;
}
if($out->SEO->fb_description){
$migrate['entry'][$m]['seo']['social']['twitter']['description'] = $out->SEO->fb_title;
$migrate['entry'][$m]['seo']['social']['facebook']['description'] = $out->SEO->fb_description;
}
// Encode it so that the SEO plugin can parse it
$migrate['entry'][$m]['seo'] = json_encode($migrate['entry'][$m]['seo']);
}
When I run my import feed I am using JSON and that ends up looking like this:
{
"seo": "{\"keywords\":[{\"keyword\":\"mark ervin big communications\"}],\"titleRaw\":{\"1\":\"The Ervin Era Has Officially Begun at Big Communications\"},\"descriptionRaw\":\"We celebrated Big Communications' first true passing of the torch last night with a cocktail hour and our own private Arc Storytelling event.\",\"social\":{\"twitter\":{\"title\":\"The Ervin Era Has Officially Begun at Big Communications\",\"description\":\"The Ervin Era Has Officially Begun at Big Communications\"},\"facebook\":{\"title\":\"The Ervin Era Has Officially Begun at Big Communications\",\"description\":\"We celebrated Big Communications' first true passing of the torch last night with a cocktail hour and our own private Arc Storytelling event.\"}}}"
}
This is what your feed map will end up looking like:
