0

For SEO purpose, I would like to remove the span tag of my pages Catalog and Product View. You can see the default render below:

Magento 2 page title h1 with inner span

How could I do that?

0

You just need to override it using your custom theme, copy the native file from:

vendor/magento/module-theme/view/frontend/templates/html/title.phtml

to:

app/design/frontend/MyCompany/MyCustomTheme/Magento_Theme/templates/html/title.phtml

You can use this content:

<?php
/**
 * @var $block \Magento\Theme\Block\Html\Title
 */
$cssClass = $block->getCssClass() ? ' ' . $block->getCssClass() : '';
$title = $block->escapeHtml($block->getPageHeading());
?>
<?php if ($title): ?>
<div class="page-title-wrapper<?= /* @escapeNotVerified */ $cssClass ?>">
    <h1 class="page-title"
        <?php if ($block->getId()): ?> id="<?= /* @escapeNotVerified */ $block->getId() ?>" <?php endif; ?>
        <?php if ($block->getAddBaseAttributeAria()): ?>
            aria-labelledby="<?= /* @escapeNotVerified */ $block->getAddBaseAttributeAria() ?>"
        <?php endif; ?>>
        <?= /* @escapeNotVerified */ $title ?>
    </h1>
    <?= $block->getChildHtml() ?>
</div>
<?php endif; ?>
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.