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

Missing canonical link in the default theme #2550

Closed
xuhdev opened this issue Apr 16, 2024 · 4 comments
Closed

Missing canonical link in the default theme #2550

xuhdev opened this issue Apr 16, 2024 · 4 comments
Labels
bug Functionality does not match expectation
Milestone

Comments

@xuhdev
Copy link
Contributor

xuhdev commented Apr 16, 2024

Search terms

default theme, canonical link

Expected Behavior

Index page generated by typedoc should include a rel canonical link.

Actual Behavior

Index page generated with the default theme does not have it.

Explanation

A rel canonical link informs a search engines that which page is the canonical page, i.e., the page that users should use. For example, the following two URLs have the exactly the same content:

A user can read the content by visiting either the of the URLs above. However, it is better for search engine to only index one of them so that the search results would be consistent and avoids content duplication in search results (while Search Engines also do some guesswork, they are not reliable and would punish the websites that do not mark canonical pages properly). By including a rel canonical link in the index page, search engines would understand the relationship between the two pages:

<link rel=canonical href=${sitemapBaseUrl}/>

The link does not have any effects to human visitors; they are only there for search engines.

(I'm getting a ton of warnings from Google Search Console)

@xuhdev xuhdev added the bug Functionality does not match expectation label Apr 16, 2024
@Gerrit0
Copy link
Collaborator

Gerrit0 commented Apr 19, 2024

This should probably only be emitted if sitemapBaseUrl is set, since otherwise it'd result in a lie... it feels off to me to use this option for emitting that, but it's not necessarily wrong... just weird...

According to that Google page, it sounds like the sitemap should also include base/ rather than base/index.html as it currently does for the page index.

If doing this... we probably ought to also add a check to handle pages which render as index.html in the modules/functions/classes directories. In their case, the / really ought not be the canonical URL, as they aren't a landing page for the directory, but caused by an exported thing named index... maybe that should actually be a special case where it's renamed to index.namespace.html or something...

@xuhdev
Copy link
Contributor Author

xuhdev commented Apr 19, 2024

Maybe we can rename sitemapBaseUrl to publicHostingBaseUrl? There are probably more unknown optimizations for public hosting that are not done...

@Gerrit0
Copy link
Collaborator

Gerrit0 commented Apr 27, 2024

I think hostedBaseUrl is reasonable, can't happen until the next minor release though

Gerrit0 added a commit that referenced this issue Apr 29, 2024
Also add canonical link to index.html when set.

Resolves #2550
@Gerrit0 Gerrit0 added this to the v0.26.0 milestone May 4, 2024
@Gerrit0
Copy link
Collaborator

Gerrit0 commented Jun 16, 2024

Fixed with TypeDoc 0.26, which is releasing 2024/06/21

@Gerrit0 Gerrit0 closed this as completed Jun 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Functionality does not match expectation
Projects
None yet
Development

No branches or pull requests

2 participants