Next.js: Can't provide multiple meta tags with the same name

Created on 21 Jan 2020  路  5Comments  路  Source: vercel/next.js

Bug report

Describe the bug

Ability to support multiple meta tags with same name. I see that there was an effort to support multiple meta tags with same property in https://github.com/zeit/next.js/pull/5800 but this still doesn't allow multiple meta tags with same name.
This is useful to supporting _"citation_author"_ for SEO indexing in Google Scholar https://scholar.google.com/intl/en-us/scholar/inclusion.html#indexing

To Reproduce

Steps to reproduce the behavior, please provide code snippets or a repository:

  1. Provide multiple meta tags with the same name in
  2. Check the output

Expected behavior

<meta name="citation_author" content="Rannels, Stephen R."> <meta name="citation_author" content="Falconieri, Mary">

should give markup as such but, currently it produces

<meta name="citation_author" content="Falconieri, Mary">

System information

  • Version of Next.js: 9.1.6
story needs investigation

Most helpful comment

I have created a minimal test case for this issue: https://github.com/zbialecki/next-meta-tag-issue

I verified that it is still present in Next.js v9.5.3-canary.9, both in dev and production mode.

I would suggest that if unique key props are provided we should be able to override this behavior and output multiple tags with the same METATYPES.

I agree with @justin-schroeder that this should be the default behavior.

All 5 comments

It looks like this used to work. We're using Swiftype meta tags to let our site be crawled but upgrading from 9.1.4 to 9.1.5 has broken (changed?) this behaviour.

const categories = ['foo', 'bar']
<Head>
  { categories.map(category => (
    <meta name="category" content={category} key={category} />
  ))}
</Head>

In 9.1.4, you get

<meta name="category" content="foo"></meta>
<meta name="category" content="bar"></meta>

In 9.1.5 +, you get

<meta name="category" content="bar"></meta>

Is this use case supposed to be supported? I'm not 100% clear whether this is a regression or not. Based on #9315 it looks like it should be supported.

Apologies for my delayed response. It should work because lot of scholar based tags are used as such.

Examples:
https://appliedcr.biomedcentral.com/articles/10.1186/s41241-020-00085-y

    <meta name="citation_reference" content="citation_journal_title=Oral Oncol; citation_title=Predictive factors of occult metastasis and prognosis of clinical stages I and II squamous cell carcinoma of the tongue and floor of the mouth; citation_author=TM Pimenta Amaral, AR Silva Freire, AL Carvalho, CA Pinto, LP Kowalski; citation_volume=40; citation_issue=8; citation_publication_date=2004; citation_pages=780-786; citation_doi=10.1016/j.oraloncology.2003.10.009; citation_id=CR2"/>
    <meta name="citation_reference" content="citation_journal_title=Oral Oncol; citation_title=Increase in head and neck cancer in younger patients due to human papillomavirus (HPV); citation_author=D Young, CC Xiao, B Murphy, M Moore, C Fakhry, TA Day; citation_volume=51; citation_issue=8; citation_publication_date=2015; citation_pages=727-730; citation_doi=10.1016/j.oraloncology.2015.03.015; citation_id=CR3"/>
    <meta name="citation_reference" content="citation_journal_title=Int J Exp Pathol; citation_title=Molecular predictors of clinical outcome in patients with head and neck squamous cell carcinoma; citation_author=GR Thomas, H Nadiminti, J Regalado; citation_volume=86; citation_issue=6; citation_publication_date=2005; citation_pages=347-363; citation_doi=10.1111/j.0959-9673.2005.00447.x; citation_id=CR4"/>

https://link.springer.com/article/10.1007/s10528-020-09951-4
https://www.academia.edu/42258245/AtCDC5_regulates_the_G2_to_M_transition_of_the_cell_cycle_and_is_critical_for_the_function_of_Arabidopsis_shoot_apical_meristem

Same issue, we're also struggling to get multi-value meta tags indexed by Swiftype which uses this exact mechanism. The next/head code makes it clear why this is happening:

https://github.com/zeit/next.js/blob/86160a5190c50ea315c7ba91d77dfb51c42bc65f/packages/next/next-server/lib/head.tsx#L50-L103

I think this is actually the correct default behavior since duplicate meta tags is a real pain that is solved here. I would suggest that if unique key props are provided we should be able to override this behavior and output multiple tags with the same METATYPES.

Is there a workaround for this?

We are facing the same issue in OpenReview: https://openreview.net/forum?id=HygBZnRctX

Google Scholar is using these meta tags to read the paper metadata.

I have created a minimal test case for this issue: https://github.com/zbialecki/next-meta-tag-issue

I verified that it is still present in Next.js v9.5.3-canary.9, both in dev and production mode.

I would suggest that if unique key props are provided we should be able to override this behavior and output multiple tags with the same METATYPES.

I agree with @justin-schroeder that this should be the default behavior.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

sospedra picture sospedra  路  3Comments

kenji4569 picture kenji4569  路  3Comments

renatorib picture renatorib  路  3Comments

knipferrc picture knipferrc  路  3Comments

havefive picture havefive  路  3Comments