-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
added canonicalUrl support #344
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
Conversation
|
Someone is attempting to deploy a commit to a Personal Account owned by @timlrx on Vercel. @timlrx first needs to authorize it. |
|
Thanks for the PR and for pointing out that non-canonical links should not be included in the sitemap. This would require modifying the generate sitemap script but it would be quite a hassle. You would have to read the markdown files and parse the frontmatter with My preference is not to implement the |
|
I have added required fixes to keep it clean but it can be added later on. I will look into it and find a way with names of the files. Maybe adding |
|
I think the best way is to modify the |
|
@onurgenes @timlrx import { useRouter } from "next/router";
const useCanonicalUrl = () => {
const router = useRouter();
const pathName = router.pathname === '/' ? '' : router.asPath;
const url = `${siteUrl}/${router.locale}${pathName}`;
return url;
};
export default useCanonicalUrl;** Used it ** import useCanonicalUrl from '@/hooks/useCanonicalUrl';
...
const url = useCanonicalUrl(); |
|
@miladezzat the proposed use for the canonicalUrl is to list a 3rd party site as the canonicalUrl, not list the current site's Url as canonical. The later is already automatically added to the SEO headers and is also what your method aims to achieve. |
|
@onurgenes it should be relatively easy to filter on the frontmatter for the |
|
Sounds awesome @timlrx! I will look into it this weekend and hopefully release my updated blog too! |
|
Finally added the latest required check @timlrx. What do you think? |
|
This pull request is being automatically deployed with Vercel (learn more). 🔍 Inspect: https://vercel.com/timlrx/tailwind-nextjs-starter-blog/CXD2pw2C1qWnQc9LckH3kYfotj7j |
|
Thanks, once the autoprefixer line has been removed, we should be good to merge it in. |
|
Auto import... Sorry for that. Now, it should be fine. |
timlrx
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the new feature!
added canonicalUrl support
added canonicalUrl support
This is a basic draft of what should be done technically but it is not enough, I guess. In some SEO tools it says "non canonical urls in sitemap" like this help page: https://help.ahrefs.com/en/articles/2652498-non-canonical-page-in-sitemap-error-in-site-audit
For this it needs to be checked if url has a canonical url tag in
frontmatter. I couldn't find a good solution for this directly but I am open to suggestions.This PR is directly related to issue #327