How can I avoid duplicate posts when using pagination in MongoDB?

I am building a blog web app where I want to display posts on the home page. I am currently using MongoDB to retrieve posts based on tags.

i want the data of the home page to be random and mixed between latest posts and popular posts.

the problem is that i don’t know to prevent duplicate data when getting more data

i am using express with mongo as database.

so after 2 pages i start getting data i already had.
i did handle it in the front-end (react)

but i want a way to handle it in the back-end
like what other websites do.

i used this as an example
the second request suppose to return data but ignore data returned in the first request (page)

db.test.aggregate([ { $match: { tags: { $in: ["python", "java"] } } }, { $sample: { size: 10 } }, { $project: { text: true } }]).toArray()