Beginners ask how to use the framework to write projects to manage the SEO of each page?
recently, I use Laravel 5.4.to write a project. Novice, I would like to ask, how do you manage the seo information of each page when you write a project?
that is, title, key and description
apart from the home page and various detail pages, how does a column (the home page of the news module, the home page of the music module, and so on) manage title, key, and description? There is a special column management setting SEO? in the background. Or on the dead code?
A novice, working on a project for the first time, I still don"t quite understand this aspect. I"d like to ask you
if it is background management:
like playing ThinkPHP3.2.3 before, you can get the current page to judge the controller name and method name to get the seo information matching the controller name and method name from the database. Now you are a little confused when playing Laravel
.
Thank you for your hard work: d
take Chestnut, for example, you have a lot of articles in a category, right? you need to optimize seo for each page. You can add a few fields seo_title,seo_description,seo_keywords to the article table, and then adjust the corresponding seo when you output the page. You can even set a default seo data. If you read something in the table, if you don't read the default, it is more advantageous to manage a large number of articles. Seo
seo is really a fickle profession. Their requirements really change no less than normal business requirements. You can save the corresponding seo template in the data table, but you will have to modify the structure of the logic layer if the template is modified later. For example, classification filter search page, may only need search terms + classification, may then have to sort fields + page numbers, so I construct in the application logic layer, write an interface constraint, and then each module writes a specific implementation to implement the logic of seo.
this may need to be based on specific project logic, for example: a project with two modules, article and commodity, is completed in two aspects:
Database:
1. Three tables: article table, commodity table, tkd table (title, keywords, description)
2, article table is associated with tkd table, commodity table and tkd table are also associated, that is, the primary key of tkd is the foreign key of article table and commodity table
code:
1. Add a tkdTrait, that has a method "tkdView" that takes three parameters: template, viewData, and tkdId.
2, on the controller, use tkdTrait and change the previous return view ($template,$viewData) to return tkdView ($template,$viewData,$tkdId).
3, now is the specific implementation of tkdView, this specific implementation is based on tkdId to go from the tkd table, take out title, keywords, description three fields, merge to $viewData above, and then return view
4 in tkdView. If there is no tkd record (in the table), then use the site-wide default tkd, to add articles in the background. Tkd does not need to be filled by default. If not, you can automatically fill in the specific content of the article and add a tkd record.
above, for reference only, specific projects, need specific design.