Note: There are a few cases of duplicates in user autocompletion which are being worked on.

Code sample generated pages should have a title

NEW
Unassigned

Status

Mozilla Developer Network
Editing
5 years ago
4 years ago

People

(Reporter: Jeremie, Unassigned)

Tracking

Details

(Reporter)

Description

5 years ago
Each time a page is generated to display a code sample, this page should have a title tag (and an a charset)

For example: https://mdn.mozillademos.org/en-US/docs/User:lmorchard/TestCodeSample$samples/Playing_with_code_samples does not have a title tag.

It would be helpful for users (if no title, the URL is display it the browser tab) and for search engine that will index those examples.

IMO, the title should reuse the title of the article it comes from with a mention to specified it's an example.

So the generated HTML should start with (the brackets express variable parts):

<!DOCTYPE html>
<html>
    <head>
    <meta charset="utf-8">
    <title>{{Article's title}} - {{Anchors where the sample comes from}} - code sample</title>

So in the case of: https://mdn.mozillademos.org/en-US/docs/User:lmorchard/TestCodeSample$samples/Playing_with_code_samples

We should have:

<!DOCTYPE html>
<html>
    <head>
    <meta charset="utf-8">
    <title>TestCodeSample - Playing with code samples - code sample</title>
Will the pages generated by code samples ever be visited directly? My understanding was that these pages would only be used within <iframe>s to show inline examples.

We could support full page examples as well, but with more features come more edge cases to account for, like this. But like anything, it's a tradeoff.
(Reporter)

Comment 2

5 years ago
(In reply to John Karahalis [:openjck] from comment #1)
> Will the pages generated by code samples ever be visited directly? 

Yes, be sure of that.

If you go to https://developer.mozilla.org/en-US/docs/User:lmorchard/TestCodeSample#Including_the_sample_in_an_iframe You'll see there is a Kuma Template to get a direct link to the code sample.

> My understanding was that these pages would only be used within <iframe>s to
> show inline examples.

Anyway, I'm the first (and not the last) to do 
Right click > This Frame > Open Frame in New Tab 
Then I explore the code using Firebug... I don't think I'm unique in that case.

And to conclude, there is no robots.txt file at the root of https://mdn.mozillademos.org/ which means that those code samples will be indexed and access directly by users (actually it's already the case in Google: https://www.google.com/search?q=https%3A%2F%2Fdeveloper.mozilla.org%2Fen-US%2Fdocs%2FUser%3Almorchard%2FTestCodeSample%23Including_the_sample_in_an_iframe).

> We could support full page examples as well, but with more features come
> more edge cases to account for, like this.

Did you take a look at the proposal I sent to dev-mdn to discuss how to deal with more complex examples.

> But like anything, it's a tradeoff.

I agree, but there is always room for improvement. This feature request is just a nice improvement. We can live without that, it's just a small detail. I have very personnal opinion about that kind of detail, but as long as I won't be able to propose a patch, I'll follow the decision made.
Thanks for sharing your thoughts. I want to be sure we provide the features you need, so I will be sure we take a look at this.
You need to log in before you can comment on or make changes to this bug.