Magento2 : Not showing Meta title & description on category page

Grep Match and extract

Diatonic chords of a pentatonic vs blues scale?

How can I remove material from this wood beam?

Why isn't Bash trap working if output is redirected to stdout?

Should I put programming books I wrote a few years ago on my resume?

If there's something that implicates the president why is there then a national security issue? (John Dowd)

Does putting salt first make it easier for attacker to bruteforce the hash?

bash vs. zsh: What are the practical differences?

C++ logging library

NUL delimited variable

What is the Leave No Trace way to dispose of coffee grounds?

How was the airlock installed on the Space Shuttle mid deck?

The origin of the Russian proverb about two hares

Housemarks (superimposed & combined letters, heraldry)

If someone intimidates another person, does the person affected gain the Frightened condition?

Mechanism of Acid Hydrolysis

Use 1 9 6 2 in this order to make 75

Multiband vertical antenna not working as expected

What STL algorithm can determine if exactly one item in a container satisfies a predicate?

What is Gilligan's full Name?

How (un)safe is it to ride barefoot?

How far would a landing Airbus A380 go until it stops with no brakes?

If I had a daughter who (is/were/was) cute, I would be very happy

Why do radiation hardened IC packages often have long leads?



Magento2 : Not showing Meta title & description on category page







.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








1















I'm getting issue with website meta info. If I will set the default meta info then it will display the same info tag for all the pages.



But when I'm trying to set the meta info for particular page then it will not display the Meta title & description.



I have set the Meta description & title for one category. In this case the Meta description & title tag showing for the same category page.



Solution I applied to display the both the tags for category pages:



I have created one observer & set the description for the current category. But when I tried to set the title then I got below error.




Recoverable Error: Object of class MagentoFrameworkViewPageTitle
could not be converted to string in
/var/www/html/htdocs/vendor/magento/framework/View/Page/Config/Renderer.php
on line 125




I used below code to set the meta title & description.




$this->_pageConfig->setMetadata('title', 'some meta title');



$this->_pageConfig->setDescription($desc);



$this->_pageConfig->setKeywords($keyWrds);




Thanks for any help.










share|improve this question






















  • check this github.com/magento/magento2/pull/11368

    – fmsthird
    Jun 4 at 11:37

















1















I'm getting issue with website meta info. If I will set the default meta info then it will display the same info tag for all the pages.



But when I'm trying to set the meta info for particular page then it will not display the Meta title & description.



I have set the Meta description & title for one category. In this case the Meta description & title tag showing for the same category page.



Solution I applied to display the both the tags for category pages:



I have created one observer & set the description for the current category. But when I tried to set the title then I got below error.




Recoverable Error: Object of class MagentoFrameworkViewPageTitle
could not be converted to string in
/var/www/html/htdocs/vendor/magento/framework/View/Page/Config/Renderer.php
on line 125




I used below code to set the meta title & description.




$this->_pageConfig->setMetadata('title', 'some meta title');



$this->_pageConfig->setDescription($desc);



$this->_pageConfig->setKeywords($keyWrds);




Thanks for any help.










share|improve this question






















  • check this github.com/magento/magento2/pull/11368

    – fmsthird
    Jun 4 at 11:37













1












1








1








I'm getting issue with website meta info. If I will set the default meta info then it will display the same info tag for all the pages.



But when I'm trying to set the meta info for particular page then it will not display the Meta title & description.



I have set the Meta description & title for one category. In this case the Meta description & title tag showing for the same category page.



Solution I applied to display the both the tags for category pages:



I have created one observer & set the description for the current category. But when I tried to set the title then I got below error.




Recoverable Error: Object of class MagentoFrameworkViewPageTitle
could not be converted to string in
/var/www/html/htdocs/vendor/magento/framework/View/Page/Config/Renderer.php
on line 125




I used below code to set the meta title & description.




$this->_pageConfig->setMetadata('title', 'some meta title');



$this->_pageConfig->setDescription($desc);



$this->_pageConfig->setKeywords($keyWrds);




Thanks for any help.










share|improve this question














I'm getting issue with website meta info. If I will set the default meta info then it will display the same info tag for all the pages.



But when I'm trying to set the meta info for particular page then it will not display the Meta title & description.



I have set the Meta description & title for one category. In this case the Meta description & title tag showing for the same category page.



Solution I applied to display the both the tags for category pages:



I have created one observer & set the description for the current category. But when I tried to set the title then I got below error.




Recoverable Error: Object of class MagentoFrameworkViewPageTitle
could not be converted to string in
/var/www/html/htdocs/vendor/magento/framework/View/Page/Config/Renderer.php
on line 125




I used below code to set the meta title & description.




$this->_pageConfig->setMetadata('title', 'some meta title');



$this->_pageConfig->setDescription($desc);



$this->_pageConfig->setKeywords($keyWrds);




Thanks for any help.







magento2 magento-2.2.5 meta-tags meta-title meta-description






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Jun 4 at 11:23









Deepak KumarDeepak Kumar

3614




3614












  • check this github.com/magento/magento2/pull/11368

    – fmsthird
    Jun 4 at 11:37

















  • check this github.com/magento/magento2/pull/11368

    – fmsthird
    Jun 4 at 11:37
















check this github.com/magento/magento2/pull/11368

– fmsthird
Jun 4 at 11:37





check this github.com/magento/magento2/pull/11368

– fmsthird
Jun 4 at 11:37










2 Answers
2






active

oldest

votes


















0














Use this code to set Metatitle,



$this->_pageConfig->getTitle()->set(__('Your Title'));






share|improve this answer























  • Hi @aravind, I have checked the same. It's also not working. It will not add the meta tag.

    – Deepak Kumar
    Jun 4 at 12:31











  • hello @DeepakKumar could you see the description and keywords set?

    – aravind
    Jun 4 at 12:33












  • The keywords showing by default. But the description also was not showing so I have added the meta description through observer. So now the description is showing but the title not.

    – Deepak Kumar
    Jun 4 at 12:44











  • could you show me the updated code of setting the title.

    – aravind
    Jun 4 at 12:52











  • I have set the title by using the above shared functions by me & the function shared by you. But nothing working for the same.

    – Deepak Kumar
    Jun 4 at 13:03


















0














Refer block and its method,




MagentoCatalogBlockCategoryView::_prepareLayout()




In this way you can set the meta title and Description,



$category = $this->getCurrentCategory();
if ($category)
$title = $category->getMetaTitle();
if ($title)
$this->pageConfig->getTitle()->set($title);

$description = $category->getMetaDescription();
if ($description)
$this->pageConfig->setDescription($description);

$keywords = $category->getMetaKeywords();
if ($keywords)
$this->pageConfig->setKeywords($keywords);

if ($this->_categoryHelper->canUseCanonicalTag())
$this->pageConfig->addRemotePageAsset(
$category->getUrl(),
'canonical',
['attributes' => ['rel' => 'canonical']]
);








share|improve this answer























    Your Answer








    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "479"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f277214%2fmagento2-not-showing-meta-title-description-on-category-page%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    Use this code to set Metatitle,



    $this->_pageConfig->getTitle()->set(__('Your Title'));






    share|improve this answer























    • Hi @aravind, I have checked the same. It's also not working. It will not add the meta tag.

      – Deepak Kumar
      Jun 4 at 12:31











    • hello @DeepakKumar could you see the description and keywords set?

      – aravind
      Jun 4 at 12:33












    • The keywords showing by default. But the description also was not showing so I have added the meta description through observer. So now the description is showing but the title not.

      – Deepak Kumar
      Jun 4 at 12:44











    • could you show me the updated code of setting the title.

      – aravind
      Jun 4 at 12:52











    • I have set the title by using the above shared functions by me & the function shared by you. But nothing working for the same.

      – Deepak Kumar
      Jun 4 at 13:03















    0














    Use this code to set Metatitle,



    $this->_pageConfig->getTitle()->set(__('Your Title'));






    share|improve this answer























    • Hi @aravind, I have checked the same. It's also not working. It will not add the meta tag.

      – Deepak Kumar
      Jun 4 at 12:31











    • hello @DeepakKumar could you see the description and keywords set?

      – aravind
      Jun 4 at 12:33












    • The keywords showing by default. But the description also was not showing so I have added the meta description through observer. So now the description is showing but the title not.

      – Deepak Kumar
      Jun 4 at 12:44











    • could you show me the updated code of setting the title.

      – aravind
      Jun 4 at 12:52











    • I have set the title by using the above shared functions by me & the function shared by you. But nothing working for the same.

      – Deepak Kumar
      Jun 4 at 13:03













    0












    0








    0







    Use this code to set Metatitle,



    $this->_pageConfig->getTitle()->set(__('Your Title'));






    share|improve this answer













    Use this code to set Metatitle,



    $this->_pageConfig->getTitle()->set(__('Your Title'));







    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Jun 4 at 12:14









    aravindaravind

    501113




    501113












    • Hi @aravind, I have checked the same. It's also not working. It will not add the meta tag.

      – Deepak Kumar
      Jun 4 at 12:31











    • hello @DeepakKumar could you see the description and keywords set?

      – aravind
      Jun 4 at 12:33












    • The keywords showing by default. But the description also was not showing so I have added the meta description through observer. So now the description is showing but the title not.

      – Deepak Kumar
      Jun 4 at 12:44











    • could you show me the updated code of setting the title.

      – aravind
      Jun 4 at 12:52











    • I have set the title by using the above shared functions by me & the function shared by you. But nothing working for the same.

      – Deepak Kumar
      Jun 4 at 13:03

















    • Hi @aravind, I have checked the same. It's also not working. It will not add the meta tag.

      – Deepak Kumar
      Jun 4 at 12:31











    • hello @DeepakKumar could you see the description and keywords set?

      – aravind
      Jun 4 at 12:33












    • The keywords showing by default. But the description also was not showing so I have added the meta description through observer. So now the description is showing but the title not.

      – Deepak Kumar
      Jun 4 at 12:44











    • could you show me the updated code of setting the title.

      – aravind
      Jun 4 at 12:52











    • I have set the title by using the above shared functions by me & the function shared by you. But nothing working for the same.

      – Deepak Kumar
      Jun 4 at 13:03
















    Hi @aravind, I have checked the same. It's also not working. It will not add the meta tag.

    – Deepak Kumar
    Jun 4 at 12:31





    Hi @aravind, I have checked the same. It's also not working. It will not add the meta tag.

    – Deepak Kumar
    Jun 4 at 12:31













    hello @DeepakKumar could you see the description and keywords set?

    – aravind
    Jun 4 at 12:33






    hello @DeepakKumar could you see the description and keywords set?

    – aravind
    Jun 4 at 12:33














    The keywords showing by default. But the description also was not showing so I have added the meta description through observer. So now the description is showing but the title not.

    – Deepak Kumar
    Jun 4 at 12:44





    The keywords showing by default. But the description also was not showing so I have added the meta description through observer. So now the description is showing but the title not.

    – Deepak Kumar
    Jun 4 at 12:44













    could you show me the updated code of setting the title.

    – aravind
    Jun 4 at 12:52





    could you show me the updated code of setting the title.

    – aravind
    Jun 4 at 12:52













    I have set the title by using the above shared functions by me & the function shared by you. But nothing working for the same.

    – Deepak Kumar
    Jun 4 at 13:03





    I have set the title by using the above shared functions by me & the function shared by you. But nothing working for the same.

    – Deepak Kumar
    Jun 4 at 13:03













    0














    Refer block and its method,




    MagentoCatalogBlockCategoryView::_prepareLayout()




    In this way you can set the meta title and Description,



    $category = $this->getCurrentCategory();
    if ($category)
    $title = $category->getMetaTitle();
    if ($title)
    $this->pageConfig->getTitle()->set($title);

    $description = $category->getMetaDescription();
    if ($description)
    $this->pageConfig->setDescription($description);

    $keywords = $category->getMetaKeywords();
    if ($keywords)
    $this->pageConfig->setKeywords($keywords);

    if ($this->_categoryHelper->canUseCanonicalTag())
    $this->pageConfig->addRemotePageAsset(
    $category->getUrl(),
    'canonical',
    ['attributes' => ['rel' => 'canonical']]
    );








    share|improve this answer



























      0














      Refer block and its method,




      MagentoCatalogBlockCategoryView::_prepareLayout()




      In this way you can set the meta title and Description,



      $category = $this->getCurrentCategory();
      if ($category)
      $title = $category->getMetaTitle();
      if ($title)
      $this->pageConfig->getTitle()->set($title);

      $description = $category->getMetaDescription();
      if ($description)
      $this->pageConfig->setDescription($description);

      $keywords = $category->getMetaKeywords();
      if ($keywords)
      $this->pageConfig->setKeywords($keywords);

      if ($this->_categoryHelper->canUseCanonicalTag())
      $this->pageConfig->addRemotePageAsset(
      $category->getUrl(),
      'canonical',
      ['attributes' => ['rel' => 'canonical']]
      );








      share|improve this answer

























        0












        0








        0







        Refer block and its method,




        MagentoCatalogBlockCategoryView::_prepareLayout()




        In this way you can set the meta title and Description,



        $category = $this->getCurrentCategory();
        if ($category)
        $title = $category->getMetaTitle();
        if ($title)
        $this->pageConfig->getTitle()->set($title);

        $description = $category->getMetaDescription();
        if ($description)
        $this->pageConfig->setDescription($description);

        $keywords = $category->getMetaKeywords();
        if ($keywords)
        $this->pageConfig->setKeywords($keywords);

        if ($this->_categoryHelper->canUseCanonicalTag())
        $this->pageConfig->addRemotePageAsset(
        $category->getUrl(),
        'canonical',
        ['attributes' => ['rel' => 'canonical']]
        );








        share|improve this answer













        Refer block and its method,




        MagentoCatalogBlockCategoryView::_prepareLayout()




        In this way you can set the meta title and Description,



        $category = $this->getCurrentCategory();
        if ($category)
        $title = $category->getMetaTitle();
        if ($title)
        $this->pageConfig->getTitle()->set($title);

        $description = $category->getMetaDescription();
        if ($description)
        $this->pageConfig->setDescription($description);

        $keywords = $category->getMetaKeywords();
        if ($keywords)
        $this->pageConfig->setKeywords($keywords);

        if ($this->_categoryHelper->canUseCanonicalTag())
        $this->pageConfig->addRemotePageAsset(
        $category->getUrl(),
        'canonical',
        ['attributes' => ['rel' => 'canonical']]
        );









        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered 2 days ago









        oscprofessionalsoscprofessionals

        37417




        37417



























            draft saved

            draft discarded
















































            Thanks for contributing an answer to Magento Stack Exchange!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f277214%2fmagento2-not-showing-meta-title-description-on-category-page%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Category:9 (number) SubcategoriesMedia in category "9 (number)"Navigation menuUpload mediaGND ID: 4485639-8Library of Congress authority ID: sh85091979ReasonatorScholiaStatistics

            Circuit construction for execution of conditional statements using least significant bitHow are two different registers being used as “control”?How exactly is the stated composite state of the two registers being produced using the $R_zz$ controlled rotations?Efficiently performing controlled rotations in HHLWould this quantum algorithm implementation work?How to prepare a superposed states of odd integers from $1$ to $sqrtN$?Why is this implementation of the order finding algorithm not working?Circuit construction for Hamiltonian simulationHow can I invert the least significant bit of a certain term of a superposed state?Implementing an oracleImplementing a controlled sum operation

            Magento 2 “No Payment Methods” in Admin New OrderHow to integrate Paypal Express Checkout with the Magento APIMagento 1.5 - Sales > Order > edit order and shipping methods disappearAuto Invoice Check/Money Order Payment methodAdd more simple payment methods?Shipping methods not showingWhat should I do to change payment methods if changing the configuration has no effects?1.9 - No Payment Methods showing upMy Payment Methods not Showing for downloadable/virtual product when checkout?Magento2 API to access internal payment methodHow to call an existing payment methods in the registration form?