Fixed Create thread javascript h1 issue

Dad.

Well-known member
In xenforo.js around line 7355, there is the function to update the page title h1 with the content you are typing while creating a thread title.

Specifically:

Code:
if (!$title.length)
   {
       $title = $('h1').first();
   }

And I found this to not work very well with my site, as my logo is an <h1>. I have a fixed navigation and I need the header to be moved back to the top, thus making this cause the issue. To fix my issue, I've simply changed MY code to be an <h2> which isn't ideal for search engines. The fix I think would work is to make the $title object something more specific:

Code:
$title = $('.pageTitle h1');

Thanks!
Mike
 

Attachments

  • h1issue.webp
    h1issue.webp
    11.4 KB · Views: 34
I would argue that wrapping your logo in h1 tags isn't the best move. I read an article recently and this sums it up quite well:

Headings are a way to define document structure and to organize content. The first heading on your site should be the one that best describes the content of your page. Sometimes this is your logo--but most of the time it’s not.

And generally I think it's a bad idea to have more than one H1 tag on a page.
 
I would argue that wrapping your logo in h1 tags isn't the best move. I read an article recently and this sums it up quite well:



And generally I think it's a bad idea to have more than one H1 tag on a page.
Fair argument, but regardless I think that it is a bit dangerous to assume we all know the best standards and we can use the tags within reason how we see fit, and so when selecting something that is going to change due to a specific function, it should in my opinion be a bit more specific than "first on the page" and rather selected by an ID or a class.
 
I have changed this in 1.3, but not before to prevent possible BC break issues with custom styles.

Note that in general, in the past, there has been an assumption of only 1 h1 per page (this was a very common SEO recommendation).
 
Yes, I read that as well. So I understand why it was done. But yeh I think its still a good idea because some people might not understand best practices, such as myself before @Chris Deeming mentioned it.
 
@Mike for more flexibility is it worth allowing the target element to be passed using a data attribute? Might there be some use cases where you'd want to show the live title elsewhere on the page instead of the h1 tag?

The default could be the new specific selector you've added but being able to override it using a data attrib would be nice.
 
Back
Top Bottom