Since I saw Symfony’s _format
routing parameter, which is used to effectively set the file type of the response, I’ve thought it would be cool to have every page on a website support more than just ‘html’ response types by adding a .{_format}
to the end of the URL and make a template version for each. Users would be able to consume the same information in different formats depending on their needs. ‘txt’, for example, would basically have just the content that would go in the “ element, in pure text format, providing a fallback or simplified view that can be read even by curl
users. ‘json’ or ‘xml’ formats might provide the content and meta data about it in a machine consumable format. You could even go all out with an ‘mp3’ format where you read the page content.
Yesterday, I took my first step toward this idea on my site by implementing my homepage in the ‘txt’ format. This was very simple since my content is already being composed in markdown, a visually pleasing structure for text content.
Obviously, adding more pages and formats will add development time. This probably wouldn’t be useful enough to be worth it for a normal site, but for my own site, I get to play with whatever cool ideas I want.