Canonical expected behavior

Hello,

I have a Ghost blog with the default Casper theme. I noticed an issue in that my URLs are being excluded from Google’s Search… including my homepage :frowning:

This is expected with the amp pages but not expected (for me at least) otherwise. When I view the source of the HTML in this example let’s say, I see the below tag: https://www.foo.software/web-vitals-how-to-track-and-analyze-web-vitals/

<link rel="canonical" href="http://www.foo.software/web-vitals-how-to-track-and-analyze-web-vitals/" />

That doesn’t seem right. The canonical should not represent the actual page. In fact, I believe it’s causing the exclusion from Google.

Am I misunderstanding? Would others care to share what they think is expected?

@adamhenson you’re running into an issue because you’re serving your site over https, but the url is configured as http. You need to set your site url to https://foo.software and all your issues should be fixed

@vikaspotluri123 - when setting up my site, I attempted to do so with SSL configured, but all the links were messed up after. I can’t remember exactly what the problem was… I think it might have been more that that.

Do you know how I could do what you say since I’m using the Docker container… on a site that already exists.

I don’t deal with deploying Ghost in Docker much, but you should be able to set the url to https:/.... by setting the url environment variable. If you run into an issue with that, it’s probably better to debug that issue rather than using the wrong url, since that can create other issues

Thanks @vikaspotluri123 - Yeah… when attempting to setup I ran into a bunch of issues around SSL. I can’t quite remember the exact. I ended up going through a trail of Google searches and eventually someone said to just configure for http even though it’s https… which I did. Things worked, except now I’m noticing this and also image uploads in posts don’t work I’m also noticing.

My concern is that even if I do fix that (I didn’t even realize the canonical was pointing to http)… I’m concerned that all pages will have canonicals that point to themselves. A canonical URL should not reference itself. I wonder if it will go away when I’ve fixed my SSL problem.

I’ll update here once I fix the SSL thing.

Can you provide a source for that? My understanding is canonical = single source of truth, and when canonical points to itself, it’s saying I am the truth. Here’s a quote from a Moz post:

It’s ok if a canonical tag points to the current URL. In other words, if URLs X, Y, and Z are duplicates, and X is the canonical version, it’s ok to put the tag pointing to X on URL X. This may sound obvious, but it’s a common point of confusion.

1 Like

Add a tag in the code for all duplicate pages, pointing to the canonical page.

https://support.google.com/webmasters/answer/139066?hl=en

I interpret this as only the duplicated pages should reference the canonical page. But I don’t work for Google :slight_smile:

Thanks for your input on this @vikaspotluri123 by the way. A lot of articles are supporting your position. Personally, I think it’s incorrect to use a canonical tag in this way but it seems harmless. Apparently my issue is bigger than this.

For context, I use the Docker container as pod deployment within a Kubernetes cluster. In my cluster I have a separate NGINX service which is a proxy for the Ghost container, among other containers. This is a standard setup, however I don’t think it’s supported by Ghost - at least from my large amounts of Googling and trial and error. There seems to be some inner workings that do a little bit too much. To me it seems like Ghost concerns itself too much with resolving links and DNS in general. It should be a bit more dumb. It seems that SSL and proxying is only possible when using the internal methods as explained here. Originally I had my blog running on http, but I migrated to https. I believe setting up from scratch in the setup I have would also be impossible - but I have yet to try it.

So, my issue seems different than the concern of my initial post. I’m going to try to figure out a way to fix things and if I do, I’ll post my steps here.

I’m going through the steps of running Ghost locally with docker-compose to mimic my production functionality, so I can troubleshoot. My setup looks something like this:

version: '3'

services:
  ghost:
    image: ghost:latest
    environment:
      - url="https://local.foo.software"
    ports:
      - "2368"
    volumes:
      - ../../../ghost-content:/var/lib/ghost/content
  nginx:
    build: ../../../../docker/foo-nginx-ghost-dev
    depends_on:
      - ghost
    ports:
      - "443:443"

Issue #1: Ghost appears to redirect to the internal host name (the upstream host from NGINX perspective). Internally, within the container this host is simply “ghost” in my case, so it redirects to “http://ghost

Created a new post about proxying and SSL in Ghost setup with SSL and external NGINX.