Typo3 Rich Snippets with typoscript - typo3

I have not been successful to implement rich snippets in my typo3 site. Basically I have tried to wrap the html tag and include meta snippets to no avail but a chain of site errors.
page.meta.itemprop.name = name
page.meta.itemprop.description = description
page.meta.itemprop.image = http://www.example.com/img/01.png
The html code is the following
<html itemscope itemtype="http://schema.org/Organization">
<meta itemprop="name" content="name">
<meta itemprop="description" content="description">
<meta itemprop="image" content="http://www.example.com/image.png">
What typoscript should be used?

This worked out for me.
config.htmlTag_stdWrap {
setContentToCurrent = 1
cObject = COA
cObject {
1 = TEXT
1.value = itemscope
1.noTrimWrap = | | |
2 = TEXT
2.value = itemtype="http://schema.org/Organization"
2.noTrimWrap = | | |
3 = TEXT
3.value = lang="en"
wrap = <html | >
}
}
page {
headerData {
4 = TEXT
4.value (
<meta itemprop="name" content="Your site Name">
<meta itemprop="description" content="Your site description">
<meta itemprop="image" content="http://www.example.com/img/01.png">
)
}
}

Related

this pixel's microdata is incomplete or incorrectly formated schema.org

I have created Facebook pixels, which connected well. When I run a debug tool, it selects sample items and lists them but once I try connecting the catalog to the pixel, it shows that the pixel is not ready. Below is the code:
<?php
$current_url = base64_encode($url="http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']);
$results = $mysqli->query("SELECT products.id,products.image,products.name,products.description, product_variant.discounted_price, product_variant.price FROM products LEFT JOIN product_variant ON products.id = product_variant.product_id where subcategory_id = 41 ORDER BY id ASC LIMIT 12");
if ($results) {
//fetch results set as object and output HTML
while($obj = $results->fetch_object()) {
$a = $obj->price;
$b = $obj->discounted_price;
$epsilon = 0;
if(!$b == $epsilon) {
$price = number_format($b,0);
} else {
$price = number_format($a,0);
}
//Microdata Tags
echo '<div itemscope itemtype="http://schema.org/Product">
<meta itemprop="brand" content="'.$obj->made_in.'">
<meta itemprop="name" content="'.$obj->name.'">
<meta itemprop="description" content="'.$obj->description.'">
<meta itemprop="productID" content="'.$obj->id.'">
<meta itemprop="url" content="https://mgcmax.com/single.php?id='.$obj->id.'">
<meta itemprop="image" content="https://www.vendor.mgcmax.com/'.$obj->image.'">
<div itemprop="value" itemscope itemtype="http://schema.org/PropertyValue">
<span itemprop="propertyID" content="item_group_id"></span>
<meta itemprop="value" content="Electroics"></meta>
</div>
<div itemprop="offers" itemscope itemtype="http://schema.org/Offer">
<link itemprop="availability" href="http://schema.org/InStock">
<link itemprop="itemCondition" href="http://schema.org/NewCondition">
<meta itemprop="product:category" content="888">
<meta itemprop="price" content="'.$price.'">
<meta itemprop="priceCurrency" content="UGX">
</div>
</div>';
}
}
?>
What could be missing for the pixels not to connect, though the debug is working?
Results of debug tool
google_product_category warning
Have the same issue here, both pixel helper tool and microdata debugger show that everything is proper, as well as several diagnostic tools in the FB business suite.
For some reason, however, the Catalog won't connect, and gives the "not ready" error.
I can also confirm it is not related to the google_product_category warning.
You can get rid of that warning by adding:
<meta itemprop="category" content="xxxx" />
The item with "item_group_id" is the facebook category, as you clearly know already.

meta-description for "tag" and "categories" pages

For HEXO blog... I know that meta-description is written in config file and works across all pages.
For blogposts I can create individual meta-descriptions and that works for the search engines.
However, my "tag" and "categories" pages get indexed now and with meta-description of home-page.
This is not good.
So I am asking if it is possible to create a custom meta-description for "tag" and "categories" pages?
Something like...
description: this is a page about {{tag}}
and
description: this is a page about {{category}}
This is the code in my head.ejs.
The site main config file has description: main config meta-description text.
<%if(metaDescription){%>
<meta name="description" content="<%= config.description %>">
<% } else if (page.description){ %>
<meta name="description" content="<%= page.description %>">
<% } else if (page.excerpt){ %>
<meta name="description" content="<%= strip_html(page.excerpt).replace(/^\s*/, '').replace(/\s*$/, '').replace(/[\n,\r]/g,'') %>">
<% } else if (page.content){ %>
<meta name="description" content="<%= strip_html(page.content).replace(/^\s*/, '').replace(/\s*$/, '').substring(0, 150).replace(/[\n,\r]/g,'') %>">
<% } else if (config.description){ %>
<meta name="description" content="<%= config.description %>">
<% }
<% if (page.keywords){ %>
<meta name="keywords" content="<%= page.keywords %>">
<% } else if (page.tags){ %>
<%
var thistags=[];
page.tags.each(function(k){
thistags.push(k.name);
}) %>
<meta name="keywords" content="<%= thistags %>">
<% } %>
This is all handled by your theme so you need to add the logic there.
You need to check if your page is a tag or category index and generate a custom description there:
let description = page.description; // Normal case when your desc comes from meta data
else if (page.tag) {
description = 'This is a page about ' + page.tag;
} else if (page.category) {
description = 'This is a page about ' + page.category;
}
// Use your description variable as you are currently doing
EDIT: based on post update (added head.ejs)
else if (page.tag) {
<meta name="description" content="<%= 'This is a page about ' + page.tag %>">
} else if (page.category) {
<meta name="description" content="<%= 'This is a page about ' + page.category %>">
}

TYPO3 FLUID blank page TYPO3

I try to create my first FLUIDTEMPLATE. But the Methode
f:layout
dont get activated.
My structure:
/fileadmin/
/fileadmin/layouts/layout.html
/fileadmin/partials/
/fileadmin/styles/
/fileadmin/templates/template.html
/fileadmin/typoscript/
/fileadmin/typoscript/01_script/setup.ts
/fileadmin/typoscript/02_object/
setup.ts:
page = PAGE
page.typeNum = 0
page.10 = FLUIDTEMPLATE
page.10 {
format = html
file = fileadmin/templates/layouts/layout.html
partialRootPath = fileadmin/templates/partials/
layoutRootPath = fileadmin/templates/layouts/
variables {
content_main < styles.content.get
content_main.select.where = colPos = 0
}
}
page.10.file.stdWrap.cObject = CASE
page.10.file.stdWrap.cObject {
key.data = levelfield:-1, backend_layout_next_level, slide
key.override.field = backend_layout
default = TEXT
default.value = fileadmin/templates/template.html
}
Layout.html:
<div id="wrapper">
<div id="header">
header
</div>
<div id="top_nav">
top_nav
</div>
<div id="left">
left
</div>
<div id="right">
right
</div>
<div id="center">
center
</div>
<div id="footer">
footer
</div>
</div>
template.html:
<f:layout name = "Layout" />
template setup:
<INCLUDE_TYPOSCRIPT: source ="DIR:fileadmin/typoscript/">
Now, if i view the webpage i only see a blank page. If i look on the code i get that:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<!--
This website is powered by TYPO3 - inspiring people to share!
TYPO3 is a free open source Content Management Framework initially created by Kasper Skaarhoj and licensed under GNU/GPL.
TYPO3 is copyright 1998-2017 of Kasper Skaarhoj. Extensions are copyright of their respective owners.
Information and contribution at https://typo3.org/
-->
<title>Fluid</title>
<meta name="generator" content="TYPO3 CMS">
<link rel="stylesheet" type="text/css" href="typo3temp/Assets/b9db200ac9.css?1491821607" media="all">
</head>
<body>
<f:layout name = "Layout" />
</body>
</html>
I am using TYPO3 v7.6.16.
Templates: Startseite.html
<f:layout name="Default" />
<f:section name="body">
<div id="wrapper">
<div id="header">
{header->f:format.raw()}
</div>
<div id="top_nav">
{top_nav->f:format.raw()}
</div>
<div id="left">
{left->f:format.raw()}
</div>
<div id="right">
{right->f:format.raw()}
</div>
<div id="center">
{center->f:format.raw()}
</div>
<div id="footer">
{footer->f:format.raw()}
</div>
</div>
</f:section>
you can configure same for inner page(Inhaltsseite) layout.
Layouts: Default.html
<f:render section="body" />
Typoscript: (setup.ts)
lib.pageTemplate = FLUIDTEMPLATE
lib.pageTemplate {
templateName = TEXT
templateName.stdWrap.cObject = CASE
templateName.stdWrap.cObject {
key.field = backend_layout
# #todo: setup all page templates
default = TEXT
default.value = Startseite
1 = TEXT
1.value = Inhaltsseite
}
templateRootPaths {
10 = fileadmin/templates/Resources/Private/Templates/
}
partialRootPaths {
10 = fileadmin/templates/Resources/Private/Partials/
}
layoutRootPaths {
10 = fileadmin/templates/Resources/Private/Layouts/
}
variables {
content = CONTENT
content {
table = tt_content
select.orderBy = sorting
slide = -1
select.where = colPos=0
}
}
}
# Page setup Configuration
page = PAGE
page {
# Your TypeNum
typeNum = 0
#Include header data if any
headerData{
}
#Include website meta
meta{
}
#Include stylesheet
includeCSS {
}
#Include Js files(In the header)
includeJS {
}
#Include Js in footer
includeJSFooter {
}
# assign template (copy fluid template object)
10 < lib.pageTemplate
}
Include setup.ts in the template->include->setup.ts from the BE.
<INCLUDE_TYPOSCRIPT:source="FILE:fileadmin/templates/Configuration/TypoScript/setup.ts" />
Greetings!
There are several issues with your example code. Lets go through them:
You should not put your templates in the fileadmin where they are (by default) accessable by web requests and editable by editors. Instead put them inside an extension under Resources/Private/.
You should not specify the layout file as your template. You have
file = fileadmin/templates/layouts/layout.html
Instead of the layout.html you should point to a template like your Template.html inside Resources/Private/Templates
In your template you then may include a layout file. But remove the whitespaces: <f:layout name="Layout" />.
Use UpperCase names for your template, layout and partial files (Template.html instead of template.html).
Use templateRootPaths and layourRootPaths and partialRootpaths instead.
So your TypoScript could look like this:
page.10 = FLUIDTEMPLATE
page.10 {
format = html
file = EXT:my_ext/Resources/Private/Templates/Template.html
partialRootPaths {
10 = EXT:my_ext/Resources/Private/Partials/
}
layoutRootPaths {
10 = EXT:my_ext/Resources/Private/Layouts/
}
templateRootPaths
10 = EXT:my_ext/Resources/Private/Templates/
}
variables {
content_main < styles.content.get
content_main.select.where = colPos = 0
}
}
you first have to create a page object in typoscript (which is missing in the typoscript above):
page = PAGE
this should be the first line in your typoscript.

How to add meta tags from widget in Orchard?

I'm trying to add some meta tags from widget (/views/parts/ folder) that gets data from database outside of orchard. I need to put them to head section, and frankly I got no idea how to achieve that.
I tried:
using (Script.Head())
{
<meta property="description" content="ABC">
}
SetMeta("ABC", "description");
But none of these work :-(
Edit: our document.cshtml code:
#using Orchard.Mvc.Html;
#using Orchard.UI.Resources;
#{
RegisterLink(new LinkEntry { Type = "image/x-icon", Rel = "shortcut icon", Href = Url.Content("~/modules/orchard.themes/Content/orchard.ico") });
string title = Convert.ToString(Model.Title);
string siteName = Convert.ToString(WorkContext.CurrentSite.SiteName);
string classForPage = "static " + Html.ClassForPage();
}
<!DOCTYPE html>
<!--[if lt IE 7]>
<html lang="#WorkContext.CurrentCulture" class="#classForPage no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]>
<html lang="#WorkContext.CurrentCulture" class="#classForPage no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]>
<html lang="#WorkContext.CurrentCulture" class="#classForPage no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!-->
<html lang="#WorkContext.CurrentCulture" class="#classForPage no-js"> <!--<![endif]-->
<head>
<meta charset="utf-8" />
<title>#Html.Title(title, siteName)</title>
<meta name="viewport" content="width=device-width">
#{
Display(Model.Head);
}
<meta property="og:title" content="#Layout.Title - #Convert.ToString(WorkContext.CurrentSite.SiteName)">
<meta property="og:site_name" content="#Convert.ToString(WorkContext.CurrentSite.SiteName)">
<meta property="og:url" content="#Request.Url">
<meta property="og:type" content="article">
<script>(function(d){d.className="dyn"+d.className.substring(6,d.className.length);})(document.documentElement);</script>
</head>
<body>
#Display(Model.Body)
#Display(Model.Tail)
</body>
</html>
Does anybody know how to achieve that?
IResourceManager provides the necessary methods.
For use it in view:
var resourceManager = WorkContext.Resolve<Orchard.UI.Resources.IResourceManager>();
resourceManager.SetMeta(new Orchard.UI.Resources.MetaEntry
{
Name = "description",
Content = "ABC"
});
But it can be also used in other places (e.g. part driver).
Edit
using SetMeta("description", "ABC") in view give the same results.
I used the following code in my layout.cshtml file before header tag and it worked.
#using (Script.Head())
{
<meta name="description" content="<your description>"/>
<meta name="keywords" content="<your keywords here>"/>
}
Enjoy!!!

any ideas why facebook like button do not display non-English letters on a wordpress blog?

All non-English (Lithuanian) elements like š,ė,ž,č and more are displayed as code which doesnt look nice. I added a facebook like button to my wordpress blog, which looks like this:
<iframe src="http://www.facebook.com/plugins/like.php?locale=lt_LT&href=<?php echo urlencode(get_permalink($post->ID)); ?>&layout=standard&show_faces=false&width=450&action=like&colorscheme=light" scrolling="no" frameborder="0" allowTransparency="true" style="border:none; position: relative; top: -150px; padding: 0 0 20px 0; overflow:hidden; width:450px; height:60px"></iframe>
You can see that I added locale=lt_LT (I'm from Lithuania)
DOCTYPE:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
Im using this:
<?php
$thumb = get_post_meta($post->ID,'_thumbnail_id',false);
$thumb = wp_get_attachment_image_src($thumb[0], false);
$thumb = $thumb[0];
$default_img = get_bloginfo('stylesheet_directory').'/images/default_icon.jpg';
?>
<?php if(is_single() || is_page()) { ?>
<meta property="og:type" content="article" />
<meta property="og:title" content="<?php single_post_title(''); ?>" />
<meta property="og:description" content="<?php
while(have_posts()):the_post();
$out_excerpt = str_replace(array("\r\n", "\r", "\n"), "", get_the_excerpt());
echo apply_filters('the_excerpt_rss', $out_excerpt);
endwhile; ?>" />
<meta property="og:url" content="<?php the_permalink(); ?>"/>
<meta property="og:image" content="<?php if ( $thumb[0] == null ) { echo $default_img; } else { echo $thumb; } ?>" />
<?php } else { ?>
<meta property="og:type" content="article" />
<meta property="og:title" content="<?php bloginfo('name'); ?>" />
<meta property="og:url" content="<?php bloginfo('url'); ?>"/>
<meta property="og:description" content="<?php bloginfo('description'); ?>" />
<meta property="og:image" content="<?php if ( $thumb[0] == null ) { echo $default_img; } else { echo $thumb; } ?>" />
<?php } ?>
Can it be a problem with DOCTYPE or something else?
The language of the button sets when you order a button from http://developers.facebook.com/docs/reference/plugins/like/
the button should have the language according to the user. example
js.src = "/ / connect.facebook.net / es_LA / all.js # xfbml = 1 & appId = 250867014982684";
that line where it says you can modify for your code es_LA language. This is html 5.
ok, for like button, try using fb developer page and get the code for htlm5; instead of iframe. i made like button in spanish some time ago, let me check my code. i'll get baack to you.