新手编码器寻找指导。我想按照Open Graph的规定将Open Graph标签添加到我的网站。我查看了我的Drupal主题在.php文件中调用meta标签的位置。如何格式化HTML代码才能在php文件中工作?对不起,我知道这是一个初学者的问题。
OPEN GRAPH提供的HTML代码
<html prefix="og: http://ogp.me/ns#">
<head>
<title>The Rock (1996)</title>
<meta property="og:title" content="The Rock" />
<meta property="og:type" content="video.movie" />
<meta property="og:url" content="http://www.imdb.com/title/tt0117500/" />
<meta property="og:image" content="http://ia.media-imdb.com/images/rock.jpg"
将加入以下来自DRUPAL THEME的PHP代码:
/* Add various META tags to HTML head. */
function montreal_preprocess_html(&$vars){
global $root;
$meta_title = array(
'#type' => 'html_tag',
'#tag' => 'meta',
'#weight' => 1,
'#attributes' => array(
'name' => 'title',
'content' => theme_get_setting('seo_title')
)
);
$meta_description = array(
'#type' => 'html_tag',
'#tag' => 'meta',
'#weight' => 2,
'#attributes' => array(
'name' => 'description',
'content' => theme_get_setting('seo_description')
)
);
$meta_keywords = array(
'#type' => 'html_tag',
'#tag' => 'meta',
'#weight' => 3,
'#attributes' => array(
'name' => 'keywords',
'content' => theme_get_setting('seo_keywords')
)
);