[SOLVED] Change name and domain of the blog

Hi everyone,
I’m thinking of changing the name of the blog and the main domain. Could you explain the correct procedure for changing the configuration in ghost anywhere? And how to solve with SEO?

I use the latest version of ghost (1.22.1)

I know how to implement redirect 301 in the actual_domain-ssl.conf file in:
/var/www/ghost/system/files

I’m not sure to remember the correct command to get ssl certificates for the new domain

Can you suggest me how to proceed correctly for ghost?

Thanks so much

For CLI-specifics, I think you need to do the following:

  1. ghost config url {new_url}
  2. ghost setup nginx // you don’t need to do this if you’re changing the subdirectory
  3. ghost restart

And how to solve with SEO?

The main thing you’ll want to do is ensure that every one of your posts/pages has a 301 redirect and that robots.txt and the sitemap files are redirected too. If you are only changing the domain name this should be fairly simple with a single redirect rule.

The other thing you may need to do is to ensure sure any links or images in your post content that are stored as absolute URLs get updated. One way to do that would be to export your content, run a search and replace on it, then import into an empty blog.

Hello, thanks for the answer.
I’m not sure to understand.
All i need for ghost config is ghost config url new_url ?

With:
ghost config url new_url I change the blog url, but I will not change the name in the configuration files?

Then:
ghost setup ssl I do not need it? I’m not changing the subdirectory, I have to completely change the name of the blog, url, domain and tld

I’m not sure I’m using a robots.txt currently.
Only the domain and the tld are changing.
Is it not possible to change the domain without having to export the contents, make a replace, and import into a new blog?

The configurations for Nginx redirect should be these, I think they are correct:

ACTUAL_DOMAIN.it.conf

server {
    listen 80;
    listen [::]:80;

    server_name www.ACTUAL_DOMAIN.it;
    root /var/www/ghost/system/nginx-root;

    include /etc/nginx/proxy.conf;
    include /etc/nginx/acme.conf;

    client_max_body_size 50m;
}

ACTUAL_DOMAIN.it-ssl.conf

server {
    listen 443 ssl http2;
    listen [::]:443 ssl http2;

    server_name ACTUAL_DOMAIN.it;

    ssl_certificate /home/user/.acme.sh/ACTUAL_DOMAIN.it/fullchain.cer;
    ssl_certificate_key /home/user/.acme.sh/ACTUAL_DOMAIN.com/ACTUAL_DOMAIN.it.key;
    include /var/www/ghost/system/files/ssl-params.conf;

    return 301 https://NEW_DOMAIN.it$request_uri;

    include /etc/nginx/acme.conf;

    client_max_body_size 50m;
}

Theoretically, even the files have to change their names, because as a name they have the current domain that will change.

ACTUAL_DOMAIN.it.conf
ACTUAL_DOMAIN.it-ssl.conf

All i need for ghost config is ghost config url new_url ?
With ghost config url new_url I change the blog url, but I will not change the name in the configuration files?

What you’re doing here is telling ghost that your blog is not at {old_url} but is at {new_url} You don’t want to change the name of the configuration files because they were generated specifically for {old_url}, rather you want to create new ones. This will leave the old configuration files, which (specifically for nginx) can allow you to configure things for {old_url}.

Then ghost setup ssl I do not need it? I’m not changing the subdirectory, I have to completely change the name of the blog, url, domain and tld

In this case, you do need to setup ssl NGINX. What this will do is update the nginx configuration to properly respond to requests from {new_domain} as well as get an SSL certificate from LetsEncrypt.

Note: I accidentally wrote ghost setup ssl instead of ghost setup nginx. You need to run ghost setup nginx, which will internally run ghost setup ssl. The SSL step is a subset of the NGINX step. Summary: run ghost setup nginx, not ghost setup ssl

If you’re trying to change the name of your blog, check out the support docs

Great, so ghost nginx setup, it should do everything automatically? Update nginx with the new domain, redirect, and ssl certificates?

Do I only have to take care of my contents and check that the URLs are correct in the posts and pages?

Excuse me if I’m insistent, my blog is in production, I do not want to risk creating problems and having it offline.

I want to proceed when everything is clear to me

Great, so ghost nginx setup, it should do everything automatically? Update nginx with the new domain, redirect, and ssl certificates?

It will not add the redirect, you need to do that manually. I would advise doing it before you run ghost setup nginx (note you flipped the terms earlier :wink:) since running that command will tell nginx to reload its configuration!

Well, I think everything is clear, I need to ask you one last question.
I have not personally installed Nginx the first time.
I noticed that in the configuration there is already an old domain and a redirect to the current one. There are two server blocks, one for each domain, each block server includes ssl certificates.
Do I need to get the ssl certificates even for the old domains with the new 301 redirect?
Or can I create a server block with the old domain that can redirect 301 to the new one without including the certificates?

This configuration for the new configuration do you think is correct?

/var/www/ghost/system/files

CURRENT_DOMAIN.it.conf

server {
    listen 80;
    listen [::]:80;

    server_name OLD_DOMAIN.com www.OLD_DOMAIN.com
                CURRENT_DOMAIN.it www.CURRENT_DOMAIN.it
                NEW_DOMAIN.it www.NEW_DOMAIN.it;

    return 301 https://NEW_DOMAIN.it$request_uri;
}

CURRENT_DOMAIN.it-ssl.conf

server {
    listen 443 ssl http2;
    listen [::]:443 ssl http2;

    server_name NEW_DOMAIN.it;

    ssl_certificate /home/user/.acme.sh/NEW_DOMAIN.it/fullchain.cer;
    ssl_certificate_key /home/user/.acme.sh/NEW_DOMAIN.com/NEW_DOMAIN.it.key;
    include /var/www/ghost/system/files/ssl-params.conf;

    return 301 https://NEW_DOMAIN.it$request_uri;

    include /etc/nginx/acme.conf;

    client_max_body_size 50m;
}

Sorry for the double post.

After the ghost setup nginx command to insert the new url and get the certificates, will I continue to get the certificates for the old domains? because the old domains will still be directed to the blog, I need all the certificates for the https

You should, since SSL renewal is managed by LetsEncrypt (specifically ACME.sh)

1 Like

Hello again,

this is what’s happening:

giacomo@silli:/var/www/ghost$ ghost config url https://New_domain.it
https://New_domain.it
giacomo@silli:/var/www/ghost$ ghost setup nginx
✔ Creating nginx config file at /var/www/ghost/system/files/New_domain.it.conf
Running sudo command: ln -sf /var/www/ghost/system/files/New_domain.it.conf /etc/nginx/sites-available/New_domain.it.conf
? Password [hidden]
Running sudo command: ln -sf /etc/nginx/sites-available/New_domain.it.conf /etc/nginx/sites-enabled/New_domain.it.conf
Running sudo command: nginx -s reload
✔ Setting up Nginx

I correctly display the new URL with the ghost config url command

However, Nginx only created the new_domain.conf file in /var/www/ghost/system/files
He did not create the new_domain-ssl.conf file

I still have the old_domain.conf and old_domain-ssl.conf files

And if I go to my home /home/giacomo/.acme.sh/ there are no certificates for the new domain.

Did I miss something?
The commands i launched are:
ghost config url new url
ghost setup nginx

nginx and ssl are separate stages; see ghost setup

Thanks, the certificates are properly working
I thought it was part of ghost setup nginx as we said in previous posts.

Can I delete old_domain.conf and old_domain-ssl.conf and set a redirect in new files (new_domain.conf and new_domain-ssl.conf) or can not I delete them?

EDIT:
The new certificates were not created in
/home/giacomo/.acme.sh/
but in:
/etc/letsencrypt/

The certificates for the www version were missing.
So I gave ghost a new URL with www and installed the new certificates, I redid the whole procedure, now everything is working, I do not know if I did well, but now have generated two new files in ghost/system /files for the version with www.

Is it possible to merge all these files?

ghost install and ghost setup automatically ask if we want ssl after the nginx stage. Not sure if doing just ghost setup nginx also asks or not. In any case, the optional ssl stage requires a previous nginx stage.

As Vikas suggested, and I agree, it’s a good practice to have an Nginx file or symlink for each domain in the sites-enabled folder. Anyway, probably you have this line in your /etc//nginx/nginx.conf file:

include /etc/nginx/sites-enabled/*;

So I guess it’s possible to merge files, although I’ve not tried that. It’s more ordered and it’s working well as they said you.

Thanks, I thought it was more correct to merge the files to get the neater code.
I will follow your advice and leave the files separate.
I can consider my “problem” solved thanks to everyone’s help

I’ve been trying to do the same thing: Migrate from blog.olddomain.com to blog.newdomain.com

I followed these steps:

 ssh into ghost
  sudo -i -u ghost-mgr
  cd /var/www/ghost
  ghost config url {enterURL}
  ghost setup nginx
  ghost setup ssl

And this worked fine.

What I haven’t managed is to set up an nginx based redirect from olddomain to newdomain

Would appreciate any help.

Thanks!

There is an Nginx redirect example at Ghost CLI optional force https - Ideas - Ghost Forum. It can also be used for different domains.

Thanks Juan,

So I guess I’ll have to do this:

server {
	listen 202.54.96.8:80;
	server_name blog.club.in;
	return 301 https://blog.club.com$request_uri;
}

Assuming I’m migrating from club.in to club.com
And where the IP address is the address of the server where Ghost is hosted.

Does this look okay to you?
And will this also migrate https://blog.club.in traffic? (or only http)

Also, another question: Which file do I modify?
Is is the one marked as default in the /etc/nginx/sites-available directory?
(screenshot for ref)

Thanks again!

Those are the old server’s IP and server_name. Usually the port is enough (listen 80 or listen 443), but sometimes including the IP fixes some problems.

That’s a 301 permanent redirect, with traffic arriving at the old address immediately redirected to the new address.

I’ve updated the redirection example on the other thread, with more details on files, etc.

1 Like