georgringer / news

TYPO3 Extension news
GNU General Public License v2.0
264 stars 358 forks source link

Canonical in pagination on List view #2245

Open aksenovaa opened 11 months ago

aksenovaa commented 11 months ago

Bug Report

Current Behavior In the news list, when you go to a page, the canonical tag is rendered without the page designation:

URL: https://aksenovaa.ru/portfolio/ canonical:

with pagination URL: https://aksenovaa.ru/portfolio/page-3/ canonical:

Routes:

    extension: News
    plugin: Pi1
    routes:
      - routePath: '/'
        _controller: 'News::list'
      - routePath: '/page-{page}'
        _controller: 'News::list'
        _arguments:
          page: 'currentPage'
      - routePath: '/tag-{tag-name}'
        _controller: 'News::list'
        _arguments:
          tag-name: overwriteDemand/tags
      - routePath: '/tag-{tag-name}/page-{page}'
        _controller: 'News::list'
        _arguments:
          tag-name: overwriteDemand/tags
          page: 'currentPage'
      - routePath: '/{news-title}'
        _controller: 'News::detail'
        _arguments:
          news-title: news
      - routePath: '/cat-{category-name}'
        _controller: 'News::list'
        _arguments:
          category-name: overwriteDemand/categories
    defaultController: 'News::list'
    defaults:
      page: '0'
    aspects:
      news-title:
#        type: NewsTitle
        type: PersistedAliasMapper
        tableName: tx_news_domain_model_news
        routeFieldName: path_segment
      page:
        type: StaticRangeMapper
        start: '1'
        end: '100'
      category-name:
#        type: NewsCategory
        type: PersistedAliasMapper
        tableName: sys_category
        routeFieldName: slug
      tag-name:
#        type: NewsTag
        type: PersistedAliasMapper
        tableName: tx_news_domain_model_tag
        routeFieldName: slug

Expected behavior/output

with pagination URL: https://aksenovaa.ru/portfolio/page-3/ canonical:

Environment

Possible Solution

when listPid is 6

[page && page["uid"] == 6]
  #    Remove tag canonical and add in
  config.disableCanonical = 1
  #    Add tag canonical
  page.headerData {
    700 = TEXT
    700 {
      stdWrap.typolink.parameter.data = TSFE:id
      stdWrap.typolink.forceAbsoluteUrl = 1
      stdWrap.typolink.returnLast = url
      stdWrap.typolink.parameter.intval = 1
      stdWrap.typolink.addQueryString = 1
      stdWrap.typolink.addQueryString.exclude = id,cHash,ysclid,open_dr,utm_campaign,utm_content,utm_medium,utm_source,utm_term
      htmlSpecialChars = 1
      wrap = <link href="|" rel="canonical" />
    }
  }
[end]