开发者

If using Ruby on Rails, how to use 1 code base for 2 websites for the HTML elements' IDs and class names to be different?

开发者 https://www.devze.com 2023-03-02 15:02 出处:网络
If using Ruby on Rails, we can set a config file to have all the different header titles, phrases, so as to different phrases on 2 different websites.

If using Ruby on Rails, we can set a config file to have all the different header titles, phrases, so as to different phrases on 2 different websites. But how about the IDs and class names (in .erb or .haml, and in .sass or .css)?

(The reason to use particular category names for the IDs and classes is so that search engines can better index the site (to see what actual content is on the site))

In .haml it is something like

#sport-watches-list

which is the same as

<div id="sport-watches-list">

and there is corresponding .sass or .css styles that go with it. So if the other website is

#fancy-cars-list

How do we make it work on Ruby on Rails? It is because there can be many such names in one page, and there are several types of pages for each website, with either watches or cars in the name:

#fancy-cars-list
  #fancy-car-row
    #fancy-car-photo
    #fancy-car-name
    #fancy-car-rating

We can have a general file with

#product-category-list

and all the markups, and use a script to replace all of them to either watches or cars, and do it also to the .sass files, but it will be quite messy. Is there a better way?

The reason to use particular category names for the IDs and classes is so that search engines can better index the site (to see what actual content is on the site开发者_开发问答)


There is no need to structure your id's and class names for Search Engines as search engines do not use this markup. You're time is better spent ensuring the content of each site is great.

Build sites for users not search engines, and the search engines will follow ;)

0

精彩评论

暂无评论...
验证码 换一张
取 消