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

Canonical Urls and others contain // #14

Open
MarcoPeretti opened this issue Jul 12, 2024 · 3 comments
Open

Canonical Urls and others contain // #14

MarcoPeretti opened this issue Jul 12, 2024 · 3 comments

Comments

@MarcoPeretti
Copy link

Hello there,

first of all, thank you for the template! it's great a very easy to use.

AHREF reports "Canonical URL has no incoming internal links" as the canonical ulr reported has a //.

I traced it back to the definition of siteBaseUrl which contains a trailing slash which affects og:image, twitter:image and the canonical url.

I fixed it by

  1. referring to images/abc instead /images/abc in blog posts
  2. removed the extra / in the canonical definition routes/(blog-article)/+layout.svelte)
@MarcoPeretti MarcoPeretti changed the title SvelteKit Group Layout and // Canonical Urls and others contain // Jul 12, 2024
@matfantinel
Copy link
Owner

Hey @MarcoPeretti , thanks for the issue report!

The steps you took make perfect sense. I am unable to do those tweaks right now, but feel free to open a pull request if you want! Otherwise, I'm adding it to my ever-growing list of things to fix 😆

Though I'd say that it'd be even better if the Image.svelte component got rid of double slashes automatically, so you don't have to manually edit any posts because of that change.

@MarcoPeretti
Copy link
Author

sure, I can submit a PR but wanted to double-check with you first as, as far as i can tell, the image component is not used. the code is the following:

	{#if post.coverImage}
		<meta property="og:image" content="{siteBaseUrl}{post.coverImage}" />
		<meta name="twitter:image" content="{siteBaseUrl}{post.coverImage}" />
	{/if}

and coverImage is just a string, whose content is set in the blog post(s). I can either update the blog posts and readme file, or create a function that strips the slash from post.coverImage.

thoughts?

@matfantinel
Copy link
Owner

@MarcoPeretti oh, for the open graph images it really is a simple string. Removing the / from there would work, but stripping double slashes would make it more resilient, which is good since it's a template.

I'd say the only requirement would be to not have to update the content of any blog posts. If it works with both /images/ and images/ that'd be perfect!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants