Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SEO: pagination information in title tag TYPO3 >=9 #1431

Open
Zellwerker opened this issue Jan 27, 2021 · 2 comments
Open

SEO: pagination information in title tag TYPO3 >=9 #1431

Zellwerker opened this issue Jan 27, 2021 · 2 comments
Labels
Milestone

Comments

@Zellwerker
Copy link
Contributor

During a SEO optimization, I noticed that the page number is not displayed when paging the newslists. In TYPO3 version 8 this was still possible.

I was able to fix that with the following code.

// GeorgRinger\News\ViewHelpers\Widget\Controller\PaginateController::indexAction()

            // BUG BEGIN: This line no longer works from TYPO3 version 9
            //$GLOBALS['TSFE']->page['title'] .= $titleAddition;
            // BUG END

            // FIX BEGIN: We use the news NewsTitleProvider instead
            $pageTitle = $GLOBALS['TSFE']->page['title'];
            if(!empty($GLOBALS['TSFE']->page['seo_title'])) {
                $pageTitle = $GLOBALS['TSFE']->page['seo_title'];
            }
            \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\GeorgRinger\News\Seo\NewsTitleProvider::class)->setTitle($pageTitle . $titleAddition);
            // FIX END 
@aksenovaa
Copy link

In \Resources\Private\News\Templates\News\List.html you need to add something like:

<f:if condition="{overwriteDemand.tags}">
	<f:then>
		<f:for each="{tags}" as="tag">
			<f:if condition="{tag.uid} == {overwriteDemand.tags}">
				<f:if condition="{tag.seotitle}">
					<n:titleTag>
						<f:format.htmlentitiesDecode>
							{tag.seotitle}{f:if(condition: '{pagination.currentPage} > 1', then: ' page {pagination.currentPage}')}
						</f:format.htmlentitiesDecode>
					</n:titleTag>
					<n:metaTag property="og:title" 
						content="{tag.seotitle -> f:format.stripTags()}{f:if(condition: '{pagination.currentPage} > 1', then: ' page {pagination.currentPage}')}" />
				</f:if>
				<f:if condition="{tag.seodescription}">
					<n:metaTag name="description" 
						content="{tag.seodescription -> f:format.stripTags()}{f:if(condition: '{pagination.currentPage} > 1', then: ' page {pagination.currentPage}')}" />
					<n:metaTag property="og:description" 
						content="{tag.seodescription -> f:format.stripTags()}{f:if(condition: '{pagination.currentPage} > 1', then: ' page {pagination.currentPage}')}" />
				</f:if>
			</f:if>
		</f:for>
	</f:then>
	<f:else>
		<f:if condition="{pagination.currentPage} > 1">
			<n:titleTag>
				{pageData.seo_title} {f:if(condition: '{pagination.currentPage} > 1', then: 'page {pagination.currentPage}')}
			</n:titleTag>
			<n:metaTag property="og:title" 
				content="{pageData.seo_title -> f:format.stripTags()}{f:if(condition: '{pagination.currentPage} > 1', then: ' page {pagination.currentPage}')}" />
			<n:metaTag name="description" 
				content="{pageData.description}{f:if(condition: '{pagination.currentPage} > 1', then: ' page {pagination.currentPage}')}" />
			<n:metaTag property="og:description" 
				content="{pageData.description -> f:format.stripTags()}{f:if(condition: '{pagination.currentPage} > 1', then: ' page {pagination.currentPage}')}" />
		</f:if>
	</f:else>
</f:if>

here i also set conditions for tags, the same can be used for category pagination

@georgringer georgringer added this to the v10 milestone Jun 3, 2022
@georgringer georgringer modified the milestones: v10, 10.1 Jun 14, 2022
@georgringer
Copy link
Owner

closing in favor of #2167

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants