Improving SEO with (Dynamic) Sitemaps in Next.js

Поділитися
Вставка
  • Опубліковано 11 лип 2021
  • In this video we'll use the next-sitemap package to generate sitemap.xml and robots.txt for our Next.js app. We'll also generate a dynamic, server rendered secondary sitemap for our app's dynamic pages.
    ---------- Course
    Want to go deeper with Next.js? Join me in my Next Level Next.js course where over 29 videos and 8 hours of content we'll build a full application from start to finish. We use TypeScript, GraphQL, Prisma, Apollo, Mapbox, Firebase and lots more. courses.leighhalliday.com/nex...
    ---------- Links
    next-sitemap - github.com/iamvishnusankar/ne...
    Starter Code - github.com/leighhalliday/next...
    Source Code - github.com/leighhalliday/next...
    ---------- Connect
    Join this channel - / @leighhalliday
    Join me on Discord - / discord

КОМЕНТАРІ • 79

  • @leighhalliday
    @leighhalliday  2 роки тому +5

    Check out my course called Next Level Next.js! A full stack course covering GraphQL, TypeScript, Apollo, Prisma, auth and lots more! next.leighhalliday.com

    • @FarhanAhmed1360
      @FarhanAhmed1360 2 роки тому +1

      working on localhost but getting internal server error 500 on production server

  • @RdozeTV
    @RdozeTV 2 роки тому +1

    This is the most clear tutorial straight to the point

  • @bigLoser818
    @bigLoser818 Рік тому

    Thanks for breaking this down into smaller, bite-size bits. Very helpful. New subscriber.

  • @imsarvesh_
    @imsarvesh_ 2 роки тому

    This channel is absolutely fantastic

  • @76Freeman
    @76Freeman 3 роки тому

    As always, great video and extremely useful. Thank you Leigh

  • @ali_kazmi_
    @ali_kazmi_ Рік тому

    Leigh Thank you so much. I needed to implement it the same way you did. It was a great help. These videos help a lot, maybe I should start making some as well.

  • @mohamedboufraine9368
    @mohamedboufraine9368 2 роки тому

    Thank you very much for this content, it´s always useful to watch your videos on nextjs :)

  • @daveisdead
    @daveisdead 2 роки тому +2

    I just wanna say how much your videos have helped me with nextjs. It’s a newer technology so there’s not a whole lot of help out there but I can always count on you for a lot of the answers. Thank you 🙏

    • @leighhalliday
      @leighhalliday  2 роки тому

      Thanks Dave!! Really happy that they are helpful!

  • @tire
    @tire Рік тому

    this is what I exactly want. Thank you sir!

  • @angelmcorrea1704
    @angelmcorrea1704 2 роки тому

    Thank you so much, very clear, to the point.

  • @LuizFerK
    @LuizFerK 3 роки тому

    This content is amazing! Thank you so much for all that extremely useful information.

  • @TheHimu30
    @TheHimu30 2 роки тому

    Very well detailed tutorial I must say

  • @Skillthrive
    @Skillthrive 2 роки тому

    So easy! I just moved my site to Next.js, so I'm looking forward to getting this installed.

  • @anthony_riera
    @anthony_riera Рік тому

    Thanks a lot for that, it was really helpful!

  • @FarhanAhmed1360
    @FarhanAhmed1360 2 роки тому

    Great video man

  • @aleemehsan761
    @aleemehsan761 2 роки тому +6

    May Allah Bless You with peace. You have solved a lot of my burden. Love from Pakistan

  • @jaza7613
    @jaza7613 2 роки тому

    Awesome!

  • @chris_and_music
    @chris_and_music 2 роки тому

    Thanks a lot! Worked perfectly for me

  • @exactzero
    @exactzero 3 роки тому

    Thanks! I've been looking for ways to solve this.

    • @leighhalliday
      @leighhalliday  3 роки тому

      Nice :D Me too, I just learned it last week for a personal project.

  • @miscany
    @miscany 2 роки тому

    Great video man. I honestly don't really use typescript, but nice job.

  • @TheVGJournal
    @TheVGJournal Рік тому

    Hey Leigh!
    Do you know if I need to switch to getServerSideProps if I am using getStaticProps in order to take advantage of next-sitemap? It seems I get all my dynamic pages, but I may be overlooking it.
    Love all your content, thanks!

  • @siumauricio2673
    @siumauricio2673 2 роки тому

    Your Goat!!

  • @tomek4132
    @tomek4132 2 роки тому

    Thanks. It helped a lot.

  • @dylanpayne9954
    @dylanpayne9954 Рік тому

    Thank you!!!!!

  • @kadyratamuradov8687
    @kadyratamuradov8687 Рік тому

    Thank you))

  • @anthon952
    @anthon952 2 роки тому

    Hi thanks for the video... A question, My website has more than 200k of pages, and it takes long to generate the sitemap in the node server, any way to handle this?

  • @israel5450
    @israel5450 7 місяців тому

    This is very useful, but how do you approach this if all the application routes are within a dynamic parent directory; like [locale]?

  • @hamed4451
    @hamed4451 2 роки тому

    whats happend for marketplaces with tones of products ? is this way good for them? i have to get all the products from the api , it takes lots of time , isnt it ?

  • @TechSignn
    @TechSignn Рік тому

    How can i do the same thing but using npm instead of yarn ?

  • @azizee
    @azizee 2 місяці тому

    hi, how do i manage the priority and lastmod? currently it show all with same priority and lastmod.

  • @niketchandivade3311
    @niketchandivade3311 2 роки тому

    How can we create sitemap index file ?

  • @ridl27
    @ridl27 2 роки тому

    ty

  • @user-uu8tt5xx8c
    @user-uu8tt5xx8c Рік тому

    i have multiple dynamic route how to do it

  • @CodeXpertiseHub
    @CodeXpertiseHub 2 роки тому +1

    Your video is helpful. But one problem when I deploy this in vercel then this server-side dynamic sitemap pages not working.
    It's showing me 500 internal Server Error.
    What is the problem here after deploy in vercel?

    • @uancamilo
      @uancamilo 2 роки тому

      yes, I was going to comment the same! I'm facing the same issue as well.

  • @youssefkanbour9308
    @youssefkanbour9308 2 роки тому

    Hello Leigh, love the tutorial.
    Say that I want to have a sitemap for all the users in my database, but there are over 20,000 users
    and to fetch these 20,000 users, i have to receive them paginated, i.e: page 1 (first 500 users), page 2 (second 500 users), and so on, and i have to keep calling until there are no more pages left.
    when creating the users sitemap, do i first load all of the 20,000 users and then generate the sitemap, and next-sitemap takes care of it by splitting it into multiple files,
    or is there a way to load a given page X of users, and creating the sitemap specific for that page: i.e: users-sitemap/5
    I'm just held back a bit by this approach, not sure what the google search engine prefers either.
    Thank you!

    • @leighhalliday
      @leighhalliday  2 роки тому

      Hey Youssef! I think you have to load all 20k user records into memory (even though that'll be done with multiple calls), and then the package will do the work of splitting them into multiple sitemap files. That said, I think a single Sitemap file can contain 50k records. I'd say just give it a try! My only worry is that it'll slow down your build/deploy considerably, so honestly at this size I would consider other approaches... maybe doing SSR with a week long cache.

  • @AbhishekSingh-ee2bo
    @AbhishekSingh-ee2bo Рік тому

    I am in a situation where I am implementing the same way and I have an Nextjs Edge function powered by Vercel. The deployment is failing on Vercel and I do not have any solution for that till now
    Please do let me know if you find the solution.

  • @TheBoglodite
    @TheBoglodite 2 роки тому

    Is this compatible with Next-SEO?

  • @funnynews341
    @funnynews341 7 місяців тому

    i have done like that, but google search console said that's my site map get over 50.000 link. But i limit under 50.000, i don't know why?

  • @vivekknShots
    @vivekknShots 2 роки тому

    Does this dynamic aproch work r if a new id comes in api after build is made in vercel for ex: like stack overflow a new question is added so a new id is made in production so will sitemap be generated for the new question ?

    • @leighhalliday
      @leighhalliday  2 роки тому +1

      Yup! It should be calculated on the fly… unless you have caching turned on. You can try by visiting the page yourself in the browser and seeing what is in the XML file.

    • @LuizGustavo-wr7rm
      @LuizGustavo-wr7rm 2 роки тому

      ​@@leighhalliday Hello. First, thanks for the tutorial. That doesn't work for me, I tried to implement in a blog and the sitemap file only update the links on build, any idea of can be happening? Thanks again!

  • @FarhanAhmed1360
    @FarhanAhmed1360 2 роки тому

    working on localhost but getting internal server error 500 on production server

  • @mlnima
    @mlnima 2 роки тому

    I have like 100k post and for example in 1 month added like 50k, if I do like this the sitemap file get so big, any solution?

  • @omarhosny9354
    @omarhosny9354 3 роки тому

    Great 👌
    I need to deploy nextjs on custom server not on vercel i don't know what to do
    Any help would be appreciated

  • @wanfahdiva4808
    @wanfahdiva4808 2 роки тому

    hi sir, i have a problem when i run yarn next-sitemap, the result of the public sitemap file becomes two, i.e. sitemap-0.xml and sitemap.xml.. is this okay for the future?

    • @skverskk
      @skverskk Рік тому

      To resolve this issue, add the following line to your next-sitemap-config.js file:
      generateIndexSitemap: false,
      Now when you run, npm run build, it will create just one xml file called sitemap.xml. The next-sitemap documentation is poor and this issue is never even brought up.

  • @rafaelreale8848
    @rafaelreale8848 2 роки тому

    and for pages that are generated after building it? Using fallback 'blocking' ?

    • @leighhalliday
      @leighhalliday  2 роки тому +1

      If you want them in your site map file you’ll have to take the dynamic approach and add them yourself.

    • @rafaelreale8848
      @rafaelreale8848 2 роки тому

      @@leighhalliday
      In this case, do you say fetch all pages previously in the api?
      I have 6 million pages. I don't think I can do this.

    • @leighhalliday
      @leighhalliday  2 роки тому

      Hmm, That sounds like a lot to put into a site map haha. Does google support that many?

    • @youssefkanbour9308
      @youssefkanbour9308 2 роки тому

      Did you figure out how the approach to fetch the 6 million pages?
      I'm struggling with something similar, but its around 500 pages, but it still would take a long time for the backend to give me all the content

    • @zidanegimiga
      @zidanegimiga Рік тому

      @@rafaelreale8848 I hope you solved your issue. Did mine by setting the siteMapSize according to the number of dynamic url options. It's avalable at the package's documentation.

  • @TshepoShere
    @TshepoShere 3 роки тому +1

    So how do we handle multiple endpoints?

    • @leighhalliday
      @leighhalliday  3 роки тому +1

      You’ll have to do multiple fetch calls to get all your data

    • @TshepoShere
      @TshepoShere 3 роки тому

      @@leighhalliday Awesome, i get it

  • @ankitsinha5127
    @ankitsinha5127 2 роки тому

    How can we implement in React js

    • @leighhalliday
      @leighhalliday  2 роки тому

      That's a complicated question Ankit... by React I am assuming you mean "create-react-app" or something outside of Next/Gatsby/Remix. And if that's the case, I am honestly not sure... you'll need some sort of custom build step or server-rendered page if you want it to be dynamic.

  • @giorgieliozashvili633
    @giorgieliozashvili633 2 роки тому

    i'm getting 404

  • @Maybehassanawad
    @Maybehassanawad 3 роки тому

    you gotta make a patreon account 😂

    • @leighhalliday
      @leighhalliday  3 роки тому +1

      Haha thanks Hassan. If you want to support you could either buy my course at next.leighhalliday.com or join the channel as a member :)

    • @Maybehassanawad
      @Maybehassanawad 3 роки тому

      @@leighhalliday happy to be a member :)

  • @Motivation-qj6id
    @Motivation-qj6id 2 роки тому

    Typescript really turn me off lol .

  • @satyamskillz
    @satyamskillz 3 роки тому

    Thanks, however I did it a few months ago, it was easy

    • @leighhalliday
      @leighhalliday  3 роки тому

      Nice! I did this for the first time just last week :)