Drupal 7 мета-тэги

Главные вкладки

Аватар пользователя papochka papochka 24 мая 2018 в 10:37

Приветствую! Такая проблема, есть нужда в генерации мета-тэгов для уже существующих страниц. Поставил модуль meta tags quick, настроил словари и прочее, но тэги так и не появляются. Подозреваю, что проблема в том, что тема самописная(не мной), и, чего-то не хватает....

Комментарии

Аватар пользователя sas@drupal.org sas@drupal.org 24 мая 2018 в 10:46

Это сделали?

Module installation
Place the entire metatags_quick directory into your Drupal sites/all/modules/ directory.
Enable Meta tags (quick) module by navigating to: Administer > Modules
Configure module-specific settings: Administer > Configuration > Search and meta data > Meta tags (quick) settings.
Import nodewords data: Administer > Configuration > Search and meta data > Meta tags (quick) settings > Upgrade from nodewords.
Meta tag fields can be added manually in content type configuration: Administer > Configuration > Content types > Manage fields.

Аватар пользователя papochka papochka 24 мая 2018 в 10:58

Это html.tpl.php

<?php

/**
 * @file
 * Default theme implementation to display the basic html structure of a single
 * Drupal page.
 *
 * Variables:
 * - $css: An array of CSS files for the current page.
 * - $language: (object) The language the site is being displayed in.
 *   $language->language contains its textual representation.
 *   $language->dir contains the language direction. It will either be 'ltr' or 'rtl'.
 * - $rdf_namespaces: All the RDF namespace prefixes used in the HTML document.
 * - $grddl_profile: A GRDDL profile allowing agents to extract the RDF data.
 * - $head_title: A modified version of the page title, for use in the TITLE tag.
 * - $head: Markup for the HEAD section (including meta tags, keyword tags, and
 *   so on).
 * - $styles: Style tags necessary to import all CSS files for the page.
 * - $scripts: Script tags necessary to load the JavaScript files and settings
 *   for the page.
 * - $page_top: Initial markup from any modules that have altered the
 *   page. This variable should always be output first, before all other dynamic
 *   content.
 * - $page: The rendered page content.
 * - $page_bottom: Final closing markup from any modules that have altered the
 *   page. This variable should always be output last, after all other dynamic
 *   content.
 * - $classes String of classes that can be used to style contextually through
 *   CSS.
 *
 * @see template_preprocess()
 * @see template_preprocess_html()
 * @see template_process()
 * <title><?php print t('ФЛАГИ. ФЛАГШТОКИ. СУВЕНИРЫ. ЗНАЧКИ. МЕДАЛИ. НАГРАДЫ. ИЗГОТОВЛЕНИЕ.  - ООО «СП «Колумб»'); ?></title>
 */
 
?>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php print $language->language?>"
      lang="<?php print $language->language?>" dir="<?php print $language->dir?>" slick-uniqueid="1"
      style="overflow: hidden;">
<head profile="<?php print $grddl_profile?>">
    <?php print $head?>
    
    <?php print $styles?>
    <?php print $scripts?>
    <meta name='yandex-verification' content='76f7ae8f7a4c9110'/>
<?php if(drupal_is_front_page()):?>    
   <title><?php print t('FLAGPOLES. SOUVENIRS. BADGES. PINS. MEDALS. AWARDS. PRODUCTION. PRODUCING.'); ?></title>
   
  <meta name="keywords" content="<?php print t('флаги, флагштоки, сувениры, значки, знаки, медали, награды, ордена, геральдика, этикетки изготовление атрибутики'); ?>" />
  <meta name="description" content="<?php print t('Флаги. Флагштоки. Изготовление флагов, сувениров, значков, медалей, орденов, наград и этикеток. Производство ООО «СР «Колумб»'); ?>" />
<?php else: ?>
    <title><?php print $head_title?></title>
<?php endif?>

</head>

<body id='onloadpage' style="display:none">
<a name="vtop"></a>
<img class="fakeheader" src="/sites/all/themes/columb/images/fakeheaders.jpg" alt="header" />
<?php print $page_top?>
<?php 
print $page?>
<?php 
print $page_bottom?>
<?php 
print listLanguage(); ?>
<!--$j('.language-switcher-locale-url li a, .language-switcher-locale-url li span').attr('lang')-->
<script>
    $j('.language-switcher-locale-url li a, .language-switcher-locale-url li span').click(
        function () {
            var redirectDomain = 'pl';
            var dmn = $j(this).attr('lang');
            var domain = $j('#lang_' + dmn).val()
            if (!$j(this).attr('href') || dmn == redirectDomain) {
                window.location = 'http://' + domain;
                return false;
            }
        }
    );
</script>
<div ><p></p></div>
<a href="#vtop" id="top"><img alt="Прокрутить вверх" src="/images/up.png"></a>
<script>
    window.onload = function() { // после загрузки страницы

        console.log('start');
        $j('.main_content').scroll(function () { // при скролле показывать и прятать блок
            console.log($j('.main_content').offset().top);

            if ($j('.main_content').offset().top < 50){
                $j("#top").show();
            } else{
                $j("#top").hide();
            }
        });
    };
</script>
<!-- Start SiteHeart code -->
<script>
(function(){
var widget_id = 610974;
_shcp =[{widget_id : widget_id}];
var lang =(navigator.language || navigator.systemLanguage 
|| navigator.userLanguage ||"en")
.substr(0,2).toLowerCase();
var url ="widget.siteheart.com/widget/sh/"+ widget_id +"/"+ lang +"/widget.js";
var hcc = document.createElement("script");
hcc.type ="text/javascript";
hcc.async =true;
hcc.src =("https:"== document.location.protocol ?"https":"http")
+"://"+ url;
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(hcc, s.nextSibling);
})();
</script>
<!-- End SiteHeart code -->
<script>
document.getElementById("onloadpage").style.display="block";
</script>

<?php
global $language;
?>
<script>
  (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  })(window,document,'script','//www.google-analytics.com/analytics.js','ga');

  ga('create', 'UA-30984922-1', 'auto');
  ga('send', 'pageview');

</script>
<!-- Yandex.Metrika counter -->
<script type="text/javascript">
    (function (d, w, c) {
        (w[geshifilter-c] = w[c] || []).push(function() {&#10;            try {&#10;                w.yaCounter21818308 = new Ya.Metrika({&#10;                    id:21818308,&#10;                    clickmap:true,&#10;                    trackLinks:true,&#10;                    accurateTrackBounce:true,&#10;                    webvisor:true,&#10;                    trackHash:true&#10;                });&#10;            } catch(e) { }&#10;        });&#10;&#10;        var n = d.getElementsByTagName(&quot;script&quot;)[0],&#10;            s = d.createElement(&quot;script&quot;),&#10;            f = function () { n.parentNode.insertBefore(s, n); };&#10;        s.type = &quot;text/javascript&quot;;&#10;        s.async = true;&#10;        s.src = &quot;https://mc.yandex.ru/metrika/watch.js&quot;;&#10;&#10;        if (w.opera == &quot;[object Opera]&quot;) {&#10;            d.addEventListener(&quot;DOMContentLoaded&quot;, f, false);&#10;        } else { f(); }&#10;    })(document, window, &quot;yandex_metrika_callbacks&quot;);&#10;&lt;/script&gt;&#10;&lt;noscript&gt;&lt;div&gt;&lt;img src=&quot;https://mc.yandex.ru/watch/21818308&quot; style=&quot;position:absolute; left:-9999px;&quot; alt=&quot;&quot; /&gt;&lt;/div&gt;&lt;/noscript&gt;&#10;&lt;!-- /Yandex.Metrika counter --&gt;&#10;&lt;?php ?&gt;&#10;&lt;? /?&gt;&#10;&lt;script&gt;&#10;  (function(i,s,o,g,r,a,m){i[&#039;GoogleAnalyticsObject&#039;]=r;i[r]=i[r]||function(){&#10;  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),&#10;  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)&#10;  })(window,document,&#039;script&#039;,&#039;//www.google-analytics.com/analytics.js&#039;,&#039;ga&#039;);&#10;&#10;  ga(&#039;create&#039;, &#039;UA-42393218-1&#039;, &#039;auto&#039;);&#10;  ga(&#039;send&#039;, &#039;pageview&#039;);&#10;&#10;&lt;/script&gt;&#10;&lt;!-- Yandex.Metrika counter --&gt;&#10;&lt;script type=&quot;text/javascript&quot;&gt;&#10;    (function (d, w, c) {&#10;        (w[c] = w[c] || []).push(function() {&#10;            try {&#10;                w.yaCounter21819406 = new Ya.Metrika({&#10;                    id:21819406,&#10;                    clickmap:true,&#10;                    trackLinks:true,&#10;                    accurateTrackBounce:true,&#10;                    webvisor:true,&#10;                    trackHash:true&#10;                });&#10;            } catch(e) { }&#10;        });&#10;&#10;        var n = d.getElementsByTagName(&quot;script&quot;)[0],&#10;            s = d.createElement(&quot;script&quot;),&#10;            f = function () { n.parentNode.insertBefore(s, n); };&#10;        s.type = &quot;text/javascript&quot;;&#10;        s.async = true;&#10;        s.src = &quot;https://mc.yandex.ru/metrika/watch.js&quot;;&#10;&#10;        if (w.opera == &quot;[object Opera]&quot;) {&#10;            d.addEventListener(&quot;DOMContentLoaded&quot;, f, false);&#10;        } else { f(); }&#10;    })(document, window, &quot;yandex_metrika_callbacks&quot;);&#10;&lt;/script&gt;&#10;&lt;noscript&gt;&lt;div&gt;&lt;img src=&quot;https://mc.yandex.ru/watch/21819406&quot; style=&quot;position:absolute; left:-9999px;&quot; alt=&quot;&quot; /&gt;&lt;/div&gt;&lt;/noscript&gt;&#10;&lt;!-- /Yandex.Metrika counter --&gt;&#10;&lt;?php ?&gt;&#10;&lt;? ?&gt;&#10;&lt;script&gt;&#10;  (function(i,s,o,g,r,a,m){i[&#039;GoogleAnalyticsObject&#039;]=r;i[r]=i[r]||function(){&#10;  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),&#10;  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)&#10;  })(window,document,&#039;script&#039;,&#039;//www.google-analytics.com/analytics.js&#039;,&#039;ga&#039;);&#10;&#10;  ga(&#039;create&#039;, &#039;UA-42390031-1&#039;, &#039;auto&#039;);&#10;  ga(&#039;send&#039;, &#039;pageview&#039;);&#10;&#10;&lt;/script&gt;&#10;&lt;!-- Yandex.Metrika counter --&gt;&#10;&lt;script type=&quot;text/javascript&quot;&gt;&#10;    (function (d, w, c) {&#10;        (w[c] = w[c] || []).push(function() {&#10;            try {&#10;                w.yaCounter21819490 = new Ya.Metrika({&#10;                    id:21819490,&#10;                    clickmap:true,&#10;                    trackLinks:true,&#10;                    accurateTrackBounce:true,&#10;                    webvisor:true,&#10;                    trackHash:true&#10;                });&#10;            } catch(e) { }&#10;        });&#10;&#10;        var n = d.getElementsByTagName(&quot;script&quot;)[0],&#10;            s = d.createElement(&quot;script&quot;),&#10;            f = function () { n.parentNode.insertBefore(s, n); };&#10;        s.type = &quot;text/javascript&quot;;&#10;        s.async = true;&#10;        s.src = &quot;https://mc.yandex.ru/metrika/watch.js&quot;;&#10;&#10;        if (w.opera == &quot;[object Opera]&quot;) {&#10;            d.addEventListener(&quot;DOMContentLoaded&quot;, f, false);&#10;        } else { f(); }&#10;    })(document, window, &quot;yandex_metrika_callbacks&quot;);&#10;&lt;/script&gt;&#10;&lt;noscript&gt;&lt;div&gt;&lt;img src=&quot;https://mc.yandex.ru/watch/21819490&quot; style=&quot;position:absolute; left:-9999px;&quot; alt=&quot;&quot; /&gt;&lt;/div&gt;&lt;/noscript&gt;&#10;&lt;!-- /Yandex.Metrika counter --&gt;&#10;&lt;?php ?&gt;&#10;&lt;/body&gt;&#10;&lt;/html&gt;&#10;&lt;!-- Update 15.01.2016 !--&gt;?>

[/geshifilter-c]

Аватар пользователя papochka papochka 24 мая 2018 в 11:00

Nodewords table not found. Please check your installation

<a href="mailto:sas@drupal.org">sas@drupal.org</a> wrote:

Это сделали?
Module installation

Place the entire metatags_quick directory into your Drupal sites/all/modules/ directory.

Enable Meta tags (quick) module by navigating to: Administer > Modules

Configure module-specific settings: Administer > Configuration > Search and meta data > Meta tags (quick) settings.

Import nodewords data: Administer > Configuration > Search and meta data > Meta tags (quick) settings > Upgrade from nodewords.
Meta tag fields can be added manually in content type configuration: Administer > Configuration > Content types > Manage fields.


Nodewords table not found. Please check your installation на вкладке апгрейд... ничего не пойму..

Аватар пользователя pselfin pselfin 25 мая 2018 в 8:10
1

Чуть не верно. Из кода видно что какой-то "умелец" и в инструменте не разобрался, и в SEO он такой же... эм... "специалист"...
Вам нужно сделать рефакторинг этого файла, а нужные скрипты вставить в друпальными блоками, модулями, в крайнем случае - в тему.

И почему metatags_quick, а не https://www.drupal.org/project/metatag ??? Я вам рекомендую последний все таки.

Аватар пользователя papochka papochka 29 мая 2018 в 17:07

Поставил metatags, все хорошо. прописывает. Но есть одно НО. Нет ли какого-нибудь решения, чтобы не в ручную прописывать тэги каждую статью, а, скажем, на основе текста автоматически сгенерировать описание и ключевые слова.

Аватар пользователя postgres postgres 29 мая 2018 в 17:54

есть.. для simplemeta есть функции api
помотрите в модуле metatags - может тоже есть

я так делал:

<?php
$meta 
simplemeta_meta_load_by_path(current_path());
            if (empty(
$meta->data['description'])){
                
$element = array(
                         
'#type' => 'html_tag',
                         
'#tag' => 'meta',
                         
'#attributes' => array( // Set up an array of attributes inside the tag
                            
'name' => 'description'
                            
'content' => $description,
                          ),
                    );
                 
$head drupal_add_html_head($element'catalog_description');
            }
?>
Аватар пользователя postgres postgres 29 мая 2018 в 18:02

Верхний код я добавлял в финальных хуках темы. А перед этим типовыми значения заполнял программно simplemeta, в какой либо своей админке:

<?php
foreach ($nodes as $node){
            
$meta2 simplemeta_meta_load_by_path('node/' $node->nid);
            if (!
$meta2) {
                
$meta2 $meta = new stdClass();
                
$meta2->language '';
                
$meta2->path "node/" $node->nid;
                
$meta2->data = array();
            }
            
$descr token_replace($values['test'], array('node'=>$node));
            
$meta2->data['description'] = $descr;

            

simplemeta_meta_save($meta2);
        }
?>
Аватар пользователя pselfin pselfin 29 мая 2018 в 18:45

Можно использовать токены. То бишь значения полей, например, заголовок статьи, название сайта, автора статьи и тд.

ыв

Аватар пользователя papochka papochka 29 мая 2018 в 22:52

Если дексрипшн можно ещё, взять 160 символов из текста, то кейворды нужно взять наиболее повторяющиеся или контекстно значимые слова

Аватар пользователя postgres postgres 30 мая 2018 в 9:06

А вот реальный вопрос - кто то еще пишет keywords? И главное зачем? Связи между keywods и местом в органике нет уже лет 10

Аватар пользователя postgres postgres 30 мая 2018 в 9:04

description - это осмысленый текст, раскрывающий соддержание заголовка на основании текста. ... если вы не хотите это шаблонизировать, то надо писать нейронную сеть. Про редактирование meta вручную скажу с иронией - что? Платить копирайтерам деньги за работу? Да никогда!!!

Аватар пользователя postgres postgres 30 мая 2018 в 15:59

Я понимаю, что такое сниппеты. Я так же знаю, что из-за всякого пренебрежения приличиями, из за таких мудрецов как мы с вами, Ярдекс и Гугл уже давно в сниппеты ставят то, что сами считают нужным. ПОтому что писать в дескрипшен по обучению детей математике: куплю продам недорого телефон метро рядом - заголовок h1 - блабла.ру - это высокое искусство, поисковиками неоцененное.

Про изначальный смысл метатэгов уже никто не помнит.