gatsby: Simple gatsby-plugin-canonical-urls Protocol Bug
Description
The gatsby-plugin-canonical-urls plugin adds a rel=canonical <link> tag to the head of each HTML page.
Here is an example of code added to the head of the html document:
<link rel="canonical" href="https://www.abc.com" data-baseprotocol="https:" data-basehost="www.abc.com">
The potential problem is with the protocol. It states the protocol is “https:”. But shouldn’t it be “https” without the colon?
How to Reproduce
- Start with the Gatsby Starter Default.
- Install the gatsby-plugin-canonical-urls plugin.
- Run “gatsby develop”
- Open “localhost:8000” in Google Chrome.
- Open the developer tools (click F12).
- Select “Elements”
- Expand the “head” section.
- Look for the rel=canonical <link> tag.
- Find the property data-baseprotocol. It should be equal to “https” not “https:”
Solution
Open the gatsby-srr.js file. And modify line 29 to remove the colon. Here is what line 29 should look like:
data-baseprotocol={parsed.protocol.slice(0, -1)}
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 15 (7 by maintainers)
Hi!
Sorry to hear you’re running into an issue. To help us best begin debugging the underlying cause, it is incredibly helpful if you’re able to create a minimal reproduction. This is a simplified example of the issue that makes it clear and obvious what the issue is and how we can begin to debug it.
If you’re up for it, we’d very much appreciate if you could provide a minimal reproduction and we’ll be able to take another look.
Thanks for using Gatsby! 💜