Want to redirect old url's to new url's

Hi, My domain is ytricks[.]com and all posts are as ytricks.com/my-post but now my domain will be ytricks.com/posts/my-post on hugo. How can i make all posts redirect properly to new url’s because my site was on wp. i am moving it to hugo.

It’s the same domain, so, you can use “aliases” in the frontmatter of your post markdown files.

1 Like

can we make it automatic for every new post?

/
to
/posts/

Thanks, it’ll work for a few old posts. :slight_smile:

That’s something that you’d use your web server’s capability for. For example, if apache, you’d use rewrite redirect rules in an .htaccess file.

1 Like

Another option to do what @RickCogley mentioned is to add an alias to your default archetype (or create a new archetype for posts and add it there):

---
aliases: 
  - /posts/{{ .Name }}/
---

For example, if you were to run hugo new posts/title-goes-here.md, then it would populate the front matter of that post like:

---
aliases:
  - /posts/title-goes-here/
---
1 Like

Do you want to keep your URLs the same? That is possible, so you don’t need to use redirects.