Hacker News new | past | comments | ask | show | jobs | submit login

You said accept headerS and since the thread was about localization I assumed you meant Accept-Language.

To answer your comment: yes you should return the same content (resource) from that URL (note the R in URL). If you want/can, you can attend to the Accept header to return it in other representation, but the content should be the same.

So /posts should return the same list of posts whether in HTML, JSON or XML representation.

But in practice content negotiation isn't used that often and people just scope APIs in their own subpath (e.g. /posts and /api/posts) since it doesn't matter that much for SEO (since Google mostly cares about crawling HTML, JSON is not going to be counted as duplicate content).




Why are XML and JSON alternates of the same resource but French and German are two different resources?


Because the world is imperfect and having URLs instead of using content negotiation makes a far better user and SEO experience so that's what we do in practice.

IOW pragmatism.


Giving the content in the user agent's configured language preference also seems pragmatic.


In what way is ignoring this pragmatic?

https://developers.google.com/search/docs/specialty/internat...

> If your site has locale-adaptive pages (that is, your site returns different content based on the perceived country or preferred language of the visitor), Google might not crawl, index, or rank all your content for different locales. This is because the default IP addresses of the Googlebot crawler appear to be based in the USA. In addition, the crawler sends HTTP requests without setting Accept-Language in the request header.

> Important: We recommend using separate locale URL configurations and annotating them with rel="alternate" hreflang annotations.




Consider applying for YC's W25 batch! Applications are open till Nov 12.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: